Skip to content

Commit

Permalink
feat: support binary field for node-pre-gyp (#109)
Browse files Browse the repository at this point in the history
  • Loading branch information
fisker authored and keithamus committed Dec 28, 2019
1 parent 2108c5a commit f284dd0
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ npx sort-package-json
- [jest](https://jestjs.io/)
- [Istanbul](https://istanbul.js.org/)
- [Mocha](https://mochajs.org/)
- [node-pre-gyp](https://github.com/mapbox/node-pre-gyp/)
- [xo](https://github.com/xojs/xo)
- [prettier](https://prettier.io/)

Expand Down
11 changes: 11 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,17 @@ const fields = [
{ key: 'man', over: sortObject },
{ key: 'directories', over: sortDirectories },
{ key: 'workspaces' },
// node-pre-gyp https://www.npmjs.com/package/node-pre-gyp#1-add-new-entries-to-your-packagejson
{
key: 'binary',
over: sortObjectBy([
'module_name',
'module_path',
'remote_path',
'package_name',
'host',
]),
},
{ key: 'scripts', over: sortScripts },
{ key: 'betterScripts', over: sortScripts },
{ key: 'husky' },
Expand Down
23 changes: 23 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,29 @@ for (const field of [
])
}

testField('binary', [
{
value: {
[UNKNOWN]: UNKNOWN,
module_name: 'node_addon_example',
module_path:
'./lib/binding/{configuration}/{node_abi}-{platform}-{arch}/',
remote_path: './{module_name}/v{version}/{configuration}/',
package_name:
'{module_name}-v{version}-{node_abi}-{platform}-{arch}.tar.gz',
host: 'https://node-pre-gyp-tests.s3-us-west-1.amazonaws.com',
},
expect: [
'module_name',
'module_path',
'remote_path',
'package_name',
'host',
UNKNOWN,
],
},
])

testField('keywords', [
{
value: ['foo', 'foo'],
Expand Down

0 comments on commit f284dd0

Please sign in to comment.