Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor file inclusion logic #1021

Merged
merged 1 commit into from
Jul 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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