Skip to content

Commit

Permalink
feat: add dependenciesMeta field (#190)
Browse files Browse the repository at this point in the history
  • Loading branch information
fisker authored May 27, 2020
1 parent d9cb77d commit 093a4ef
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 0 deletions.
1 change: 1 addition & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ const fields = [
{ key: 'resolutions', over: sortObject },
{ key: 'dependencies', over: sortObject },
{ key: 'devDependencies', over: sortObject },
{ key: 'dependenciesMeta', over: sortObjectBy(undefined, true) },
{ key: 'peerDependencies', over: sortObject },
// TODO: only sort depth = 2
{ key: 'peerDependenciesMeta', over: sortObjectBy(undefined, true) },
Expand Down
8 changes: 8 additions & 0 deletions tests/deps.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,11 @@ test('peerDependenciesMeta', macro.sortObjectAlphabetically, {
// TODO: don't use snapshot, find a esaier way for review
expect: 'snapshot',
})

// peerDependenciesMeta
test('dependenciesMeta', macro.sortObjectAlphabetically, {
path: 'dependenciesMeta',
maxDepth: 2,
// TODO: don't use snapshot, find a esaier way for review
expect: 'snapshot',
})
Binary file modified tests/snapshots/cli.js.snap
Binary file not shown.
52 changes: 52 additions & 0 deletions tests/snapshots/deps.js.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,58 @@ The actual snapshot is saved in `deps.js.snap`.

Generated by [AVA](https://avajs.dev).

## dependenciesMeta

> Should sort `dependenciesMeta` as object.
{
input: `{␊
"dependenciesMeta": {␊
"z": "z",␊
"a": "a"␊
}␊
}`,
options: undefined,
output: `{␊
"dependenciesMeta": {␊
"a": "a",␊
"z": "z"␊
}␊
}`,
pretty: true,
}

> Should sort `dependenciesMeta` as object.
{
input: `{␊
"dependenciesMeta": {␊
"z": {␊
"z": "z",␊
"a": "a"␊
},␊
"a": {␊
"z": "z",␊
"a": "a"␊
}␊
}␊
}`,
options: undefined,
output: `{␊
"dependenciesMeta": {␊
"a": {␊
"a": "a",␊
"z": "z"␊
},␊
"z": {␊
"a": "a",␊
"z": "z"␊
}␊
}␊
}`,
pretty: true,
}

## peerDependenciesMeta

> Should sort `peerDependenciesMeta` as object.
Expand Down
Binary file modified tests/snapshots/deps.js.snap
Binary file not shown.
2 changes: 2 additions & 0 deletions tests/snapshots/main.js.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ Generated by [AVA](https://avajs.dev).
"contributors": "contributors",␊
"cpu": "cpu",␊
"dependencies": "dependencies",␊
"dependenciesMeta": "dependenciesMeta",␊
"description": "description",␊
"devDependencies": "devDependencies",␊
"directories": "directories",␊
Expand Down Expand Up @@ -165,6 +166,7 @@ Generated by [AVA](https://avajs.dev).
"resolutions": "resolutions",␊
"dependencies": "dependencies",␊
"devDependencies": "devDependencies",␊
"dependenciesMeta": "dependenciesMeta",␊
"peerDependencies": "peerDependencies",␊
"peerDependenciesMeta": "peerDependenciesMeta",␊
"optionalDependencies": "optionalDependencies",␊
Expand Down
Binary file modified tests/snapshots/main.js.snap
Binary file not shown.

0 comments on commit 093a4ef

Please sign in to comment.