Skip to content

Commit

Permalink
fix lib path resolving in scripts/paths.js (microsoft#56)
Browse files Browse the repository at this point in the history
* fix lib path resolving in scripts/paths.js

* throw error when it fails to resolve the lib path by require('napajs/build').paths
  • Loading branch information
helloshuangzi authored Aug 24, 2017
1 parent b3bcded commit c61f1bd
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions scripts/paths.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,18 @@

let path = require('path');

Object.defineProperty(exports, 'root', {
get: function() {
let rootPath = path.resolve(__dirname, '..');
// Output the path to stdout for cmake/gyp commands.
process.stdout.write(rootPath);
return rootPath;
}
});

Object.defineProperty(exports, 'lib', {
get: function() {
let libPath = path.resolve(__dirname, '../inc/' + getLibraryName('napa'));
let libPath = path.resolve(__dirname, '../bin/' + getLibraryName('napa'));
// Output the path to stdout for cmake/gyp commands.
process.stdout.write(libPath);
return libPath;
Expand All @@ -29,6 +38,10 @@ function getLibraryName(originalName) {
return 'lib' + originalName + '.dylib';
} else if (process.platform === 'linux') {
return 'lib' + originalName + '.so';
} else {
throw new Error(
'Failed to resolve the library name of "' + originalName +
'" because your platform type "' + process.platform +
'"is not supported by require(\'napajs/build\').paths');
}
return originalName;
}

0 comments on commit c61f1bd

Please sign in to comment.