Skip to content

Commit

Permalink
Fix "pattern is too long" error when running np (#633)
Browse files Browse the repository at this point in the history
  • Loading branch information
revelt authored Mar 19, 2022
1 parent b1939c7 commit 20117a4
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions source/npm/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,16 +154,20 @@ function npmignoreExistsInPackageRootDir() {
return fs.existsSync(path.resolve(rootDir, '.npmignore'));
}

function excludeGitAndNodeModulesPaths(singlePath) {
return !singlePath.startsWith('.git/') && !singlePath.startsWith('node_modules/');
}

async function getFilesIgnoredByDotnpmignore(pkg, fileList) {
const allowList = await ignoreWalker({
const allowList = (await ignoreWalker({
path: pkgDir.sync(),
ignoreFiles: ['.npmignore']
});
})).filter(singlePath => excludeGitAndNodeModulesPaths(singlePath));
return fileList.filter(minimatch.filter(getIgnoredFilesGlob(allowList, pkg.directories), {matchBase: true, dot: true}));
}

function filterFileList(globArray, fileList) {
const globString = globArray.length > 1 ? `{${globArray}}` : globArray[0];
const globString = globArray.length > 1 ? `{${globArray.filter(singlePath => excludeGitAndNodeModulesPaths(singlePath))}}` : globArray[0];
return fileList.filter(minimatch.filter(globString, {matchBase: true, dot: true})); // eslint-disable-line unicorn/no-fn-reference-in-iterator
}

Expand Down

0 comments on commit 20117a4

Please sign in to comment.