Skip to content

Commit

Permalink
feat: add support for volta (#257)
Browse files Browse the repository at this point in the history
  • Loading branch information
mataha committed May 1, 2022
1 parent 3e4ff74 commit 9ab64e0
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions defaultRules.md
Expand Up @@ -92,6 +92,7 @@ _Note: when a specific key order is used, any other keys will be sorted in the e
| packageManager | |
| engines | Key sort |
| engineStrict | Key sort |
| volta | Key order: `node`, `npm`, `yarn` |
| languageName | |
| os | |
| cpu | |
Expand Down
3 changes: 3 additions & 0 deletions index.js
Expand Up @@ -124,6 +124,8 @@ const sortPrettierConfig = onObject(
]),
)

const sortVolta = sortObjectBy(['node', 'npm', 'yarn'])

// See https://docs.npmjs.com/misc/scripts
const defaultNpmScripts = new Set([
'install',
Expand Down Expand Up @@ -290,6 +292,7 @@ const fields = [
{ key: 'packageManager' },
{ key: 'engines', over: sortObject },
{ key: 'engineStrict', over: sortObject },
{ key: 'volta', over: sortVolta },
{ key: 'languageName' },
{ key: 'os' },
{ key: 'cpu' },
Expand Down
14 changes: 14 additions & 0 deletions tests/fields.js
Expand Up @@ -186,6 +186,20 @@ test('directories', macro.sortObject, {
},
})

test('volta', macro.sortObject, {
path: 'volta',
value: {
yarn: '0.0.0',
npm: '0.0.0',
node: '0.0.0',
},
expect: {
node: '0.0.0',
npm: '0.0.0',
yarn: '0.0.0',
},
})

test('contributors', (t) => {
const contributors = {
contributors: [
Expand Down
2 changes: 2 additions & 0 deletions tests/snapshots/main.js.md
Expand Up @@ -107,6 +107,7 @@ Generated by [AVA](https://avajs.dev).
"umd:main": "umd:main",␊
"unpkg": "unpkg",␊
"version": "version",␊
"volta": "volta",␊
"workspaces": "workspaces",␊
"xo": "xo"␊
}`,
Expand Down Expand Up @@ -201,6 +202,7 @@ Generated by [AVA](https://avajs.dev).
"packageManager": "packageManager",␊
"engines": "engines",␊
"engineStrict": "engineStrict",␊
"volta": "volta",␊
"languageName": "languageName",␊
"os": "os",␊
"cpu": "cpu",␊
Expand Down
Binary file modified tests/snapshots/main.js.snap
Binary file not shown.

0 comments on commit 9ab64e0

Please sign in to comment.