Skip to content

Commit

Permalink
use filter functioon
Browse files Browse the repository at this point in the history
  • Loading branch information
benibenj committed Jul 17, 2024
1 parent f55228d commit 2c95bcb
Showing 1 changed file with 1 addition and 9 deletions.
10 changes: 1 addition & 9 deletions src/package.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1978,15 +1978,7 @@ export async function printAndValidatePackagedFiles(files: IFile[], cwd: string,
// the package does not include at least one file for each include pattern
else if (manifest.files !== undefined && manifest.files.length > 0 && !options.allowUnusedFilesPattern) {
const originalFilePaths = files.map(f => util.vsixPathToFilePath(f.path));

const unusedIncludePatterns = [];
for (const includePattern of manifest.files) {
const hasMatchingFile = originalFilePaths.some(file => minimatch(file, includePattern, MinimatchOptions));
if (!hasMatchingFile) {
unusedIncludePatterns.push(includePattern);
}
}

const unusedIncludePatterns = manifest.files.filter(includePattern => !originalFilePaths.some(filePath => minimatch(filePath, includePattern, MinimatchOptions)));
if (unusedIncludePatterns.length > 0) {
let message = '';
message += `The following include patterns in the ${chalk.bold('"files"')} property in package.json do not match any files packaged in the extension:\n`;
Expand Down

0 comments on commit 2c95bcb

Please sign in to comment.