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

Honors --yarn flag for prepublish step #376

Merged
merged 1 commit into from Jul 23, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/package.ts
Expand Up @@ -864,14 +864,14 @@ function defaultPackagePath(cwd: string, manifest: Manifest): string {
return path.join(cwd, `${manifest.name}-${manifest.version}.vsix`);
}

function prepublish(cwd: string, manifest: Manifest): Promise<Manifest> {
function prepublish(cwd: string, manifest: Manifest, useYarn: boolean = false): Promise<Manifest> {
if (!manifest.scripts || !manifest.scripts['vscode:prepublish']) {
return Promise.resolve(manifest);
}

console.warn(`Executing prepublish script 'npm run vscode:prepublish'...`);
console.warn(`Executing prepublish script '${useYarn ? 'yarn' : 'npm'} run vscode:prepublish'...`);

return exec('npm run vscode:prepublish', { cwd, maxBuffer: 5000 * 1024 })
return exec(`${useYarn ? 'yarn' : 'npm'} run vscode:prepublish`, { cwd, maxBuffer: 5000 * 1024 })
.then(({ stdout, stderr }) => {
process.stdout.write(stdout);
process.stderr.write(stderr);
Expand All @@ -884,7 +884,7 @@ export async function pack(options: IPackageOptions = {}): Promise<IPackageResul
const cwd = options.cwd || process.cwd();

let manifest = await readManifest(cwd);
manifest = await prepublish(cwd, manifest);
manifest = await prepublish(cwd, manifest, options.useYarn);

const files = await collect(manifest, options);
if (files.length > 100) {
Expand Down Expand Up @@ -926,7 +926,7 @@ export function listFiles(cwd = process.cwd(), useYarn = false, packagedDependen
*/
export function ls(cwd = process.cwd(), useYarn = false, packagedDependencies?: string[]): Promise<void> {
return readManifest(cwd)
.then(manifest => prepublish(cwd, manifest))
.then(manifest => prepublish(cwd, manifest, useYarn))
.then(manifest => collectFiles(cwd, useYarn, packagedDependencies))
.then(files => files.forEach(f => console.log(`${f}`)));
}