Skip to content

Commit

Permalink
validate the package if pre-release flag is passed (#666)
Browse files Browse the repository at this point in the history
* fix: validate the package if pre-release flag is passed

* Update src/publish.ts

* Update src/publish.ts

Co-authored-by: João Moreno <[email protected]>
  • Loading branch information
sandy081 and joaomoreno authored Dec 31, 2021
1 parent e5af890 commit f4a8264
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/publish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,22 @@ export async function publish(options: IPublishOptions = {}): Promise<any> {
throw new Error(`Invalid extension VSIX manifest. ${err}`);
}

if (options.preRelease) {
let isPreReleasePackage = false;
try {
isPreReleasePackage = !!vsix.xmlManifest.PackageManifest.Metadata[0].Properties[0].Property.some(
p => p.$.Id === 'Microsoft.VisualStudio.Code.PreRelease'
);
} catch (err) {
throw new Error(`Invalid extension VSIX manifest. ${err}`);
}
if (!isPreReleasePackage) {
throw new Error(
`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.`
);
}
}

await _publish(packagePath, vsix.manifest, { ...options, target });
}
} else {
Expand Down

0 comments on commit f4a8264

Please sign in to comment.