Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ Output:
"name": "prettier-package-json",
"version": "1.0.1",
"main": "src/index.js",
"files": ["src"]
"files": ["src", "CHANGELOG.md"]
}
```

Expand Down
13 changes: 4 additions & 9 deletions src/sort-files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,7 @@ type FilterFn<T> = (...args: T[]) => boolean;
const not = <T>(filterFn: FilterFn<T>) => (arg: T) => !filterFn(arg); // prettier-ignore
const or = <T>(...filterFns: FilterFn<T>[]) => (arg: T) => filterFns.some((fn) => fn(arg)); // prettier-ignore

const ALWAYS_INCLUDED = [
/^package.json$/,
/^README.*/i,
/^CHANGE(S|LOG).*/i,
/^HISTORY.*/i,
/^LICEN(C|S)E.*/i,
/^NOTICE.*/i
]
const ALWAYS_INCLUDED = [/^package.json$/, /^README.*/i, /^LICEN(C|S)E.*/i, /^copying.*/i]
.map((regex) => (filepath: string) => regex.test(filepath))
.reduce((a, b) => or(a, b));

Expand All @@ -39,7 +32,9 @@ const ALWAYS_EXCLUDED = [
'node_modules',
'config.gypi',
'*.orig',
'package-lock.json'
'package-lock.json',
'yarn.lock',
'pnpm-lock.yaml'
]
.map((glob) => minimatch.filter(glob) as any as FilterFn<string>)
.reduce((a, b) => or(a, b));
Expand Down
2 changes: 2 additions & 0 deletions tests/__fixtures__/package-1.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
"src/",
"HISTORY",
"CHANGELOG.md",
"LICENSE",
"COPYING",
"readme.md",
"package-lock.json"
],
Expand Down
20 changes: 15 additions & 5 deletions tests/__snapshots__/command-line.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ Object {
},
\\"files\\": [
\\"src/\\",
\\"test/\\"
\\"test/\\",
\\"CHANGELOG.md\\",
\\"HISTORY\\"
],
\\"keywords\\": [
\\"formatter\\",
Expand Down Expand Up @@ -83,7 +85,9 @@ Object {
},
\\"files\\": [
\\"src/\\",
\\"test/\\"
\\"test/\\",
\\"CHANGELOG.md\\",
\\"HISTORY\\"
],
\\"scripts\\": {
\\"precommit\\": \\"./bin/prettier-package-json --write && git add package.json\\",
Expand Down Expand Up @@ -130,7 +134,9 @@ Object {
},
\\"files\\": [
\\"src/\\",
\\"test/\\"
\\"test/\\",
\\"CHANGELOG.md\\",
\\"HISTORY\\"
],
\\"scripts\\": {
\\"precommit\\": \\"./bin/prettier-package-json --write && git add package.json\\",
Expand Down Expand Up @@ -177,7 +183,9 @@ Object {
},
\\"files\\": [
\\"src/\\",
\\"test/\\"
\\"test/\\",
\\"CHANGELOG.md\\",
\\"HISTORY\\"
],
\\"scripts\\": {
\\"precommit\\": \\"./bin/prettier-package-json --write && git add package.json\\",
Expand Down Expand Up @@ -259,7 +267,9 @@ Object {
},
\\"files\\": [
\\"src/\\",
\\"test/\\"
\\"test/\\",
\\"CHANGELOG.md\\",
\\"HISTORY\\"
],
\\"scripts\\": {
\\"precommit\\": \\"./bin/prettier-package-json --write && git add package.json\\",
Expand Down