feat(scripts): support platform flag
This commit is contained in:
parent
d21a3379a5
commit
498768578d
1 changed files with 5 additions and 7 deletions
|
@ -29,7 +29,7 @@ if (tomlContent.package && tomlContent.package.name) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const argv = parseArgs(process.argv.slice(2), {
|
const argv = parseArgs(process.argv.slice(2), {
|
||||||
boolean: ['release'],
|
boolean: ['release', 'platform'],
|
||||||
})
|
})
|
||||||
|
|
||||||
const platform = os.platform()
|
const platform = os.platform()
|
||||||
|
@ -58,19 +58,17 @@ switch (platform) {
|
||||||
|
|
||||||
const targetDir = argv.release ? 'release' : 'debug'
|
const targetDir = argv.release ? 'release' : 'debug'
|
||||||
|
|
||||||
let subcommand = argv._[0] || path.join('target', targetDir, `${moduleName}.node`)
|
const platformName = argv.platform ? `.${platform}` : ''
|
||||||
const parsedDist = path.parse(subcommand)
|
|
||||||
|
|
||||||
if (parsedDist.ext && parsedDist.ext !== '.node') {
|
let subcommand = argv._[0] || path.join('target', targetDir, `${moduleName}${platformName}.node`)
|
||||||
throw new TypeError('Dist file must be end with .node extension')
|
const parsedDist = path.parse(subcommand)
|
||||||
}
|
|
||||||
|
|
||||||
if (!parsedDist.name || parsedDist.name === '.') {
|
if (!parsedDist.name || parsedDist.name === '.') {
|
||||||
subcommand = moduleName
|
subcommand = moduleName
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!parsedDist.ext) {
|
if (!parsedDist.ext) {
|
||||||
subcommand = `${subcommand}.node`
|
subcommand = `${subcommand}${platformName}.node`
|
||||||
}
|
}
|
||||||
|
|
||||||
const pos = __dirname.indexOf('node_modules')
|
const pos = __dirname.indexOf('node_modules')
|
||||||
|
|
Loading…
Reference in a new issue