From 498768578d87b6ccbc5134e2967de9d8364362ce Mon Sep 17 00:00:00 2001 From: LongYinan Date: Mon, 27 Apr 2020 00:11:19 +0800 Subject: [PATCH] feat(scripts): support platform flag --- scripts/napi.js | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/scripts/napi.js b/scripts/napi.js index 77f829d6..0638b25b 100755 --- a/scripts/napi.js +++ b/scripts/napi.js @@ -29,7 +29,7 @@ if (tomlContent.package && tomlContent.package.name) { } const argv = parseArgs(process.argv.slice(2), { - boolean: ['release'], + boolean: ['release', 'platform'], }) const platform = os.platform() @@ -58,19 +58,17 @@ switch (platform) { const targetDir = argv.release ? 'release' : 'debug' -let subcommand = argv._[0] || path.join('target', targetDir, `${moduleName}.node`) -const parsedDist = path.parse(subcommand) +const platformName = argv.platform ? `.${platform}` : '' -if (parsedDist.ext && parsedDist.ext !== '.node') { - throw new TypeError('Dist file must be end with .node extension') -} +let subcommand = argv._[0] || path.join('target', targetDir, `${moduleName}${platformName}.node`) +const parsedDist = path.parse(subcommand) if (!parsedDist.name || parsedDist.name === '.') { subcommand = moduleName } if (!parsedDist.ext) { - subcommand = `${subcommand}.node` + subcommand = `${subcommand}${platformName}.node` } const pos = __dirname.indexOf('node_modules')