Skip to content

Commit d83f7ba

Browse files
committed
Don't package default readme if a path is provided
1 parent dd70844 commit d83f7ba

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

src/main.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,9 @@ module.exports = function (argv: string[]): void {
7474
// default must remain undefined for dependencies or we will fail to load defaults from package.json
7575
.option('--dependencies', 'Enable dependency detection via npm or yarn', undefined)
7676
.option('--no-dependencies', 'Disable dependency detection via npm or yarn', undefined)
77-
.action(({ tree, yarn, packagedDependencies, ignoreFile, dependencies }) =>
78-
main(ls({ tree, useYarn: yarn, packagedDependencies, ignoreFile, dependencies }))
77+
.option('--readme-path <path>', 'Path to README file (defaults to README.md)')
78+
.action(({ tree, yarn, packagedDependencies, ignoreFile, dependencies, readmePath }) =>
79+
main(ls({ tree, useYarn: yarn, packagedDependencies, ignoreFile, dependencies, readmePath }))
7980
);
8081

8182
program

src/package.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1610,8 +1610,6 @@ const defaultIgnore = [
16101610
'**/.vscode-test-web/**',
16111611
];
16121612

1613-
const notIgnored = ['!package.json', '!README.md'];
1614-
16151613
async function collectAllFiles(
16161614
cwd: string,
16171615
dependencies: 'npm' | 'yarn' | 'none' | undefined,
@@ -1647,8 +1645,12 @@ function collectFiles(
16471645
dependencies: 'npm' | 'yarn' | 'none' | undefined,
16481646
dependencyEntryPoints?: string[],
16491647
ignoreFile?: string,
1650-
manifestFileIncludes?: string[]
1648+
manifestFileIncludes?: string[],
1649+
readmePath?: string,
16511650
): Promise<string[]> {
1651+
readmePath = readmePath ?? 'README.md';
1652+
const notIgnored = ['!package.json', `!${readmePath}`];
1653+
16521654
return collectAllFiles(cwd, dependencies, dependencyEntryPoints).then(files => {
16531655
files = files.filter(f => !/\r$/m.test(f));
16541656

@@ -1756,7 +1758,7 @@ export function collect(manifest: Manifest, options: IPackageOptions = {}): Prom
17561758
const ignoreFile = options.ignoreFile || undefined;
17571759
const processors = createDefaultProcessors(manifest, options);
17581760

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

17621764
return processFiles(processors, files);
@@ -1915,6 +1917,7 @@ export interface IListFilesOptions {
19151917
readonly ignoreFile?: string;
19161918
readonly dependencies?: boolean;
19171919
readonly prepublish?: boolean;
1920+
readonly readmePath?: string;
19181921
}
19191922

19201923
/**
@@ -1928,7 +1931,7 @@ export async function listFiles(options: IListFilesOptions = {}): Promise<string
19281931
await prepublish(cwd, manifest, options.useYarn);
19291932
}
19301933

1931-
return await collectFiles(cwd, getDependenciesOption(options), options.packagedDependencies, options.ignoreFile, manifest.files);
1934+
return await collectFiles(cwd, getDependenciesOption(options), options.packagedDependencies, options.ignoreFile, manifest.files, options.readmePath);
19321935
}
19331936

19341937
interface ILSOptions {
@@ -1937,6 +1940,7 @@ interface ILSOptions {
19371940
readonly packagedDependencies?: string[];
19381941
readonly ignoreFile?: string;
19391942
readonly dependencies?: boolean;
1943+
readonly readmePath?: string;
19401944
}
19411945

19421946
/**

0 commit comments

Comments
 (0)