-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Strip slashes from package files list results
Fix: npm/cli#2007
- Loading branch information
Showing
2 changed files
with
57 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
const t = require('tap') | ||
const packlist = require('../') | ||
t.test('should strip / from package.json files array entry results', t => { | ||
const path = t.testdir({ | ||
'package.json': JSON.stringify({ | ||
files: [ | ||
// include without slash, then exclude with it | ||
'somedir', | ||
'!somedir/', | ||
|
||
// other way around | ||
'otherdir/', | ||
'!otherdir', | ||
|
||
// now including it that way | ||
'!incldir/', | ||
'incldir', | ||
|
||
// exclude without slash, then include with it | ||
'!dist', | ||
'dist/', | ||
'!dist/foo/*.src' | ||
] | ||
}), | ||
otherdir: { | ||
donotinclude: '' | ||
}, | ||
somedir: { | ||
donotinclude: '' | ||
}, | ||
incldir: { | ||
yesinclude: '' | ||
}, | ||
foo: '', | ||
dist: { | ||
foo: { | ||
'foo.src': '', | ||
'foo.result': '' | ||
}, | ||
bar: '', | ||
baz: { | ||
boo: '', | ||
'boo.src': '' | ||
} | ||
} | ||
}) | ||
return packlist({path}).then(res => t.strictSame(res, [ | ||
'dist/bar', | ||
'dist/baz/boo', | ||
'incldir/yesinclude', | ||
'package.json', | ||
'dist/foo/foo.result', | ||
'dist/baz/boo.src' | ||
])) | ||
}) |