Skip to content

Commit

Permalink
fix: prepublish should run before version bump
Browse files Browse the repository at this point in the history
closes #187
  • Loading branch information
joaomoreno committed Nov 2, 2021
1 parent 768d15b commit 535fa75
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
9 changes: 4 additions & 5 deletions src/package.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<void> {
export async function prepublish(cwd: string, manifest: Manifest, useYarn?: boolean): Promise<void> {
if (!manifest.scripts || !manifest.scripts['vscode:prepublish']) {
return;
}
Expand Down Expand Up @@ -1468,11 +1468,7 @@ async function getPackagePath(cwd: string, manifest: Manifest, options: IPackage

export async function pack(options: IPackageOptions = {}): Promise<IPackageResult> {
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));

Expand All @@ -1489,6 +1485,9 @@ export async function pack(options: IPackageOptions = {}): Promise<IPackageResul
}

export async function packageCommand(options: IPackageOptions = {}): Promise<any> {
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);
Expand Down
5 changes: 4 additions & 1 deletion src/publish.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -51,6 +51,9 @@ export async function publish(options: IPublishOptions = {}): Promise<any> {
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) {
Expand Down

0 comments on commit 535fa75

Please sign in to comment.