From 535fa75a9d33ad28a342ad68a7306d78ad889f81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Moreno?= Date: Tue, 2 Nov 2021 16:20:33 +0100 Subject: [PATCH] fix: prepublish should run before version bump closes #187 --- src/package.ts | 9 ++++----- src/publish.ts | 5 ++++- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/package.ts b/src/package.ts index df352c84..88ea88fa 100644 --- a/src/package.ts +++ b/src/package.ts @@ -1429,7 +1429,7 @@ function getDefaultPackageName(manifest: Manifest, options: IPackageOptions): st return `${manifest.name}-${version}.vsix`; } -async function prepublish(cwd: string, manifest: Manifest, useYarn?: boolean): Promise { +export async function prepublish(cwd: string, manifest: Manifest, useYarn?: boolean): Promise { if (!manifest.scripts || !manifest.scripts['vscode:prepublish']) { return; } @@ -1468,11 +1468,7 @@ async function getPackagePath(cwd: string, manifest: Manifest, options: IPackage export async function pack(options: IPackageOptions = {}): Promise { const cwd = options.cwd || process.cwd(); - const manifest = await readManifest(cwd); - - await prepublish(cwd, manifest, options.useYarn); - const files = await collect(manifest, options); const jsFiles = files.filter(f => /\.js$/i.test(f.path)); @@ -1489,6 +1485,9 @@ export async function pack(options: IPackageOptions = {}): Promise { + const cwd = options.cwd || process.cwd(); + const manifest = await readManifest(cwd); + await prepublish(cwd, manifest, options.useYarn); await versionBump(options); const { packagePath, files } = await pack(options); diff --git a/src/publish.ts b/src/publish.ts index 3c47ac40..63fc65a6 100644 --- a/src/publish.ts +++ b/src/publish.ts @@ -1,6 +1,6 @@ import * as fs from 'fs'; import { ExtensionQueryFlags, PublishedExtension } from 'azure-devops-node-api/interfaces/GalleryInterfaces'; -import { pack, readManifest, versionBump } from './package'; +import { pack, readManifest, versionBump, prepublish } from './package'; import * as tmp from 'tmp'; import { getPublisher } from './store'; import { getGalleryAPI, read, getPublishedUrl, log, getHubUrl } from './util'; @@ -51,6 +51,9 @@ export async function publish(options: IPublishOptions = {}): Promise { await _publish(packagePath, vsix.manifest, { ...options, target }); } } else { + const cwd = options.cwd || process.cwd(); + const manifest = await readManifest(cwd); + await prepublish(cwd, manifest, options.useYarn); await versionBump(options); if (options.targets) {