-
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.
fix: make sure we filter workspace package content even if we only in…
…clude some files from it
- Loading branch information
Showing
2 changed files
with
114 additions
and
6 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,88 @@ | ||
'use strict' | ||
|
||
const t = require('tap') | ||
const packlist = require('../') | ||
|
||
t.test('correctly filters files from workspace subdirectory', async (t) => { | ||
const pkg = t.testdir({ | ||
'package.json': JSON.stringify({ | ||
name: 'root', | ||
version: '1.0.0', | ||
files: ['docs/*.txt'], | ||
main: 'index.js', | ||
workspaces: ['./docs'], | ||
}), | ||
'index.js': '', | ||
docs: { | ||
'package.json': JSON.stringify({ | ||
name: 'docs', | ||
version: '1.0.0', | ||
main: 'index.js', | ||
files: ['*.txt'], | ||
}), | ||
'bar.txt': '', | ||
'foo.txt': '', | ||
'readme.md': '', | ||
test: { | ||
'index.js': '', | ||
}, | ||
}, | ||
}) | ||
|
||
const files = await packlist({ path: pkg }) | ||
t.same(files, [ | ||
'index.js', | ||
'package.json', | ||
'docs/readme.md', // readme.md is always included | ||
'docs/bar.txt', | ||
'docs/foo.txt', | ||
]) | ||
}) | ||
|
||
t.test('does not filter based on package.json if subdirectory is not a workspace', async (t) => { | ||
const pkg = t.testdir({ | ||
'package.json': JSON.stringify({ | ||
name: 'root', | ||
version: '1.0.0', | ||
files: ['docs/*.txt'], | ||
main: 'index.js', | ||
// this test needs a workspace to exist, but that workspace cannot be the one we include | ||
// files from | ||
workspaces: ['./unrelated'], | ||
}), | ||
'index.js': '', | ||
docs: { | ||
'package.json': JSON.stringify({ | ||
name: 'docs', | ||
version: '1.0.0', | ||
main: 'index.js', | ||
files: ['bar.txt', 'foo.txt'], | ||
}), | ||
'bar.txt': '', | ||
'baz.txt': '', | ||
'foo.txt': '', | ||
'readme.md': '', | ||
test: { | ||
'index.js': '', | ||
}, | ||
}, | ||
unrelated: { | ||
'package.json': JSON.stringify({ | ||
name: 'unrelated', | ||
version: '1.0.0', | ||
main: 'index.js', | ||
}), | ||
'index.js': '', | ||
}, | ||
}) | ||
|
||
const files = await packlist({ path: pkg }) | ||
t.same(files, [ | ||
'index.js', | ||
'package.json', | ||
'docs/readme.md', // readme.md is always included | ||
'docs/bar.txt', | ||
'docs/baz.txt', // was _not_ filtered | ||
'docs/foo.txt', | ||
]) | ||
}) |