Skip to content

Commit

Permalink
New files since last release: additional test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
bunysae committed Aug 2, 2020
1 parent fba3ab4 commit 2fa3cf5
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 4 deletions.
2 changes: 1 addition & 1 deletion integration-test
6 changes: 4 additions & 2 deletions source/npm/util.js
Expand Up @@ -150,7 +150,7 @@ function getFilesNotIncludedInFilesProperty(pkg, fileList) {
} catch (_) {}
}

let result = fileList.filter(minimatch.filter(getIgnoredFilesGlob(globArrayForFilesAndDirectories, pkg.directories), {matchBase: true}));
const result = fileList.filter(minimatch.filter(getIgnoredFilesGlob(globArrayForFilesAndDirectories, pkg.directories), {matchBase: true}));
return result.filter(minimatch.filter(getDefaultIncludedFilesGlob(pkg.main), {nocase: true, matchBase: true}));
}

Expand All @@ -170,6 +170,7 @@ function getDefaultIncludedFilesGlob(mainFile) {
if (mainFile) {
filesAlwaysIncluded.push(mainFile);
}

return `!{${filesAlwaysIncluded}}`;
}

Expand All @@ -193,7 +194,8 @@ function getIgnoredFilesGlob(globArrayFromFilesProperty, packageDirectories) {
'node_modules/**/*',
'npm-debug.log',
'package-lock.json',
'.git/**/*'
'.git/**/*',
'.git'
];

// Test files are assumed not to be part of the package
Expand Down
1 change: 1 addition & 0 deletions test/fixtures/npmignore/README.txt
@@ -0,0 +1 @@
File is always included in package.
1 change: 1 addition & 0 deletions test/fixtures/npmignore/readme.md
@@ -0,0 +1 @@
File is always included in package.
5 changes: 5 additions & 0 deletions test/integration.js
@@ -1,6 +1,11 @@
const test = require('ava');
const execa = require('execa');

test.before(async () => {
await execa('git', ['submodule', 'update', '--remote']);
await execa('npm', ['i'], {cwd: 'integration-test'});
});

test('Integration tests', async t => {
await execa('ava', {cwd: 'integration-test'});
t.pass();
Expand Down
4 changes: 3 additions & 1 deletion test/npmignore.js
Expand Up @@ -6,7 +6,9 @@ const newFiles = [
'source/ignore.txt',
'source/pay_attention.txt',
'.hg',
'test/file.txt'
'test/file.txt',
'readme.md',
'README.txt'
];

test('ignored files using file-attribute in package.json with one file', async t => {
Expand Down

0 comments on commit 2fa3cf5

Please sign in to comment.