Skip to content

Commit

Permalink
Merge pull request #1025 from microsoft:benibenj/well-lion
Browse files Browse the repository at this point in the history
Don't package default readme if a path is provided and default is ignored
  • Loading branch information
benibenj authored Jul 18, 2024
2 parents 2e3e3bc + d83f7ba commit 3b1b774
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
5 changes: 3 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,9 @@ module.exports = function (argv: string[]): void {
// default must remain undefined for dependencies or we will fail to load defaults from package.json
.option('--dependencies', 'Enable dependency detection via npm or yarn', undefined)
.option('--no-dependencies', 'Disable dependency detection via npm or yarn', undefined)
.action(({ tree, yarn, packagedDependencies, ignoreFile, dependencies }) =>
main(ls({ tree, useYarn: yarn, packagedDependencies, ignoreFile, dependencies }))
.option('--readme-path <path>', 'Path to README file (defaults to README.md)')
.action(({ tree, yarn, packagedDependencies, ignoreFile, dependencies, readmePath }) =>
main(ls({ tree, useYarn: yarn, packagedDependencies, ignoreFile, dependencies, readmePath }))
);

program
Expand Down
14 changes: 9 additions & 5 deletions src/package.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1613,8 +1613,6 @@ const defaultIgnore = [
'**/.vscode-test-web/**',
];

const notIgnored = ['!package.json', '!README.md'];

async function collectAllFiles(
cwd: string,
dependencies: 'npm' | 'yarn' | 'none' | undefined,
Expand Down Expand Up @@ -1650,8 +1648,12 @@ function collectFiles(
dependencies: 'npm' | 'yarn' | 'none' | undefined,
dependencyEntryPoints?: string[],
ignoreFile?: string,
manifestFileIncludes?: string[]
manifestFileIncludes?: string[],
readmePath?: string,
): Promise<string[]> {
readmePath = readmePath ?? 'README.md';
const notIgnored = ['!package.json', `!${readmePath}`];

return collectAllFiles(cwd, dependencies, dependencyEntryPoints).then(files => {
files = files.filter(f => !/\r$/m.test(f));

Expand Down Expand Up @@ -1759,7 +1761,7 @@ export function collect(manifest: Manifest, options: IPackageOptions = {}): Prom
const ignoreFile = options.ignoreFile || undefined;
const processors = createDefaultProcessors(manifest, options);

return collectFiles(cwd, getDependenciesOption(options), packagedDependencies, ignoreFile, manifest.files).then(fileNames => {
return collectFiles(cwd, getDependenciesOption(options), packagedDependencies, ignoreFile, manifest.files, options.readmePath).then(fileNames => {
const files = fileNames.map(f => ({ path: util.filePathToVsixPath(f), localPath: path.join(cwd, f) }));

return processFiles(processors, files);
Expand Down Expand Up @@ -1918,6 +1920,7 @@ export interface IListFilesOptions {
readonly ignoreFile?: string;
readonly dependencies?: boolean;
readonly prepublish?: boolean;
readonly readmePath?: string;
}

/**
Expand All @@ -1931,7 +1934,7 @@ export async function listFiles(options: IListFilesOptions = {}): Promise<string
await prepublish(cwd, manifest, options.useYarn);
}

return await collectFiles(cwd, getDependenciesOption(options), options.packagedDependencies, options.ignoreFile, manifest.files);
return await collectFiles(cwd, getDependenciesOption(options), options.packagedDependencies, options.ignoreFile, manifest.files, options.readmePath);
}

interface ILSOptions {
Expand All @@ -1940,6 +1943,7 @@ interface ILSOptions {
readonly packagedDependencies?: string[];
readonly ignoreFile?: string;
readonly dependencies?: boolean;
readonly readmePath?: string;
}

/**
Expand Down

0 comments on commit 3b1b774

Please sign in to comment.