style: naming refactor in napi.js

This commit is contained in:
LongYinan 2020-06-21 17:00:40 +08:00
parent c5d57969fe
commit fce24f0566
No known key found for this signature in database
GPG key ID: A3FFE134A3E20881
2 changed files with 7 additions and 8 deletions

View file

@ -118,9 +118,8 @@ Because libraries that depend on this crate must be loaded into a Node executabl
To run tests: To run tests:
```sh ```sh
cd test_module yarn --cwd ./test_module build
npm run build yarn test
npm test
``` ```
## Features table ## Features table

View file

@ -63,17 +63,17 @@ const targetDir = argv.release ? 'release' : 'debug'
const platformName = argv.musl ? '.musl' : argv.platform ? `.${platform}` : '' const platformName = argv.musl ? '.musl' : argv.platform ? `.${platform}` : ''
let subcommand = let distModulePath =
argv._[0] || argv._[0] ||
path.join('target', targetDir, `${moduleName}${platformName}.node`) path.join('target', targetDir, `${moduleName}${platformName}.node`)
const parsedDist = path.parse(subcommand) const parsedDist = path.parse(distModulePath)
if (!parsedDist.name || parsedDist.name === '.') { if (!parsedDist.name || parsedDist.name === '.') {
subcommand = moduleName distModulePath = moduleName
} }
if (!parsedDist.ext) { if (!parsedDist.ext) {
subcommand = `${subcommand}${platformName}.node` distModulePath = `${distModulePath}${platformName}.node`
} }
const pos = __dirname.indexOf('node_modules') const pos = __dirname.indexOf('node_modules')
@ -87,4 +87,4 @@ const dylibContent = fs.readFileSync(
), ),
) )
fs.writeFileSync(subcommand, dylibContent) fs.writeFileSync(distModulePath, dylibContent)