From c61f1bd0810040ea8ab847a3c43469035cfddc07 Mon Sep 17 00:00:00 2001 From: Allen Wang Date: Thu, 24 Aug 2017 16:28:09 -0700 Subject: [PATCH] fix lib path resolving in scripts/paths.js (#56) * fix lib path resolving in scripts/paths.js * throw error when it fails to resolve the lib path by require('napajs/build').paths --- scripts/paths.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/scripts/paths.js b/scripts/paths.js index 786c196e..0bfb11e9 100644 --- a/scripts/paths.js +++ b/scripts/paths.js @@ -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; @@ -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; }