Skip to content

Commit f4a8264

Browse files
sandy081joaomoreno
andauthored
validate the package if pre-release flag is passed (#666)
* fix: validate the package if pre-release flag is passed * Update src/publish.ts * Update src/publish.ts Co-authored-by: João Moreno <joao.moreno@microsoft.com>
1 parent e5af890 commit f4a8264

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/publish.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,22 @@ export async function publish(options: IPublishOptions = {}): Promise<any> {
5151
throw new Error(`Invalid extension VSIX manifest. ${err}`);
5252
}
5353

54+
if (options.preRelease) {
55+
let isPreReleasePackage = false;
56+
try {
57+
isPreReleasePackage = !!vsix.xmlManifest.PackageManifest.Metadata[0].Properties[0].Property.some(
58+
p => p.$.Id === 'Microsoft.VisualStudio.Code.PreRelease'
59+
);
60+
} catch (err) {
61+
throw new Error(`Invalid extension VSIX manifest. ${err}`);
62+
}
63+
if (!isPreReleasePackage) {
64+
throw new Error(
65+
`Cannot use '--pre-release' flag with a package that was not packaged as pre-release. Please package it using the '--pre-release' flag and publish again.`
66+
);
67+
}
68+
}
69+
5470
await _publish(packagePath, vsix.manifest, { ...options, target });
5571
}
5672
} else {

0 commit comments

Comments
 (0)