-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: exclude non-root README.md/LICENSE files (#173)
BREAKING CHANGE: The files array can now be used to exclude non-root readme, license, licence, and copying files. Co-authored-by: rahulio96 <rahulgithub96@gmail.com>
- Loading branch information
1 parent
21ed893
commit 24344a2
Showing
3 changed files
with
104 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
// exclude readme, license, and licnce files if package.json | ||
// files array includes !readme, !license, or !licence | ||
'use strict' | ||
|
||
const Arborist = require('@npmcli/arborist') | ||
const t = require('tap') | ||
const packlist = require('../') | ||
|
||
const pkg = t.testdir({ | ||
'package.json': JSON.stringify({ | ||
files: [ | ||
'**/*.js', | ||
'!readme.md', | ||
'!licence', | ||
'!license', | ||
'!copying', | ||
], | ||
|
||
}), | ||
'readme.md': 'one', | ||
licence: 'two', | ||
license: 'tre', | ||
copying: 'for', | ||
lib: { | ||
'readme.md': 'one', | ||
licence: 'two', | ||
license: 'tre', | ||
copying: 'for', | ||
a: { | ||
'readme.md': 'one', | ||
licence: 'two', | ||
license: 'tre', | ||
copying: 'for', | ||
b: { | ||
'readme.md': 'one', | ||
licence: 'two', | ||
license: 'tre', | ||
copying: 'for', | ||
c: { | ||
'readme.md': 'one', | ||
licence: 'two', | ||
license: 'tre', | ||
copying: 'for', | ||
'file.txt': 'one', | ||
'c.js': 'two', | ||
}, | ||
'file.txt': 'one', | ||
'b.js': 'two', | ||
}, | ||
'file.txt': 'one', | ||
'a.js': 'two', | ||
}, | ||
} }) | ||
|
||
t.test('package with negated readme, licence and license files', async (t) => { | ||
const arborist = new Arborist({ path: pkg }) | ||
const tree = await arborist.loadActual() | ||
const files = await packlist(tree) | ||
t.same(files, [ | ||
'copying', | ||
'licence', | ||
'license', | ||
'lib/a/a.js', | ||
'lib/a/b/b.js', | ||
'lib/a/b/c/c.js', | ||
'package.json', | ||
'readme.md', | ||
]) | ||
}) |