Skip to content

Commit

Permalink
fixes #625
Browse files Browse the repository at this point in the history
  • Loading branch information
joaomoreno committed Oct 22, 2021
1 parent b45bf93 commit ecab6bf
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ module.exports = function (argv: string[]): void {
'Personal Access Token (defaults to VSCE_PAT environment variable)',
process.env['VSCE_PAT']
)
.option('-t, --target <target>', 'Target architecture')
.option('-t, --target <targets...>', 'Target architectures')
.option('-m, --message <commit message>', 'Commit message used when calling `npm version`.')
.option('--no-git-tag-version', 'Do not create a version commit and tag when calling `npm version`.')
.option('-i, --packagePath <paths...>', 'Publish the provided VSIX packages.')
Expand Down Expand Up @@ -181,7 +181,7 @@ module.exports = function (argv: string[]): void {
publish({
pat,
version,
target,
targets: target,
commitMessage: message,
gitTagVersion,
packagePath,
Expand Down
26 changes: 20 additions & 6 deletions src/publish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const tmpName = denodeify<string>(tmp.tmpName);
export interface IPublishOptions {
readonly packagePath?: string[];
readonly version?: string;
readonly target?: string;
readonly targets?: string[];
readonly commitMessage?: string;
readonly gitTagVersion?: boolean;
readonly cwd?: string;
Expand All @@ -32,7 +32,7 @@ export async function publish(options: IPublishOptions = {}): Promise<any> {
if (options.packagePath) {
if (options.version) {
throw new Error(`Both options not supported simultaneously: 'packagePath' and 'version'.`);
} else if (options.target) {
} else if (options.targets) {
throw new Error(`Both options not supported simultaneously: 'packagePath' and 'target'.`);
}

Expand All @@ -51,13 +51,27 @@ export async function publish(options: IPublishOptions = {}): Promise<any> {
} else {
await versionBump(options.cwd, options.version, options.commitMessage, options.gitTagVersion);

const packagePath = await tmpName();
const packageResult = await pack({ ...options, packagePath });
await _publish(packagePath, packageResult.manifest, options);
if (options.targets) {
for (const target of options.targets) {
const packagePath = await tmpName();
const packageResult = await pack({ ...options, target, packagePath });
await _publish(packagePath, packageResult.manifest, { ...options, target });
}
} else {
const packagePath = await tmpName();
const packageResult = await pack({ ...options, packagePath });
await _publish(packagePath, packageResult.manifest, options);
}
}
}

async function _publish(packagePath: string, manifest: Manifest, options: IPublishOptions) {
export interface IInternalPublishOptions {
readonly target?: string;
readonly pat?: string;
readonly noVerify?: boolean;
}

async function _publish(packagePath: string, manifest: Manifest, options: IInternalPublishOptions) {
if (!options.noVerify && manifest.enableProposedApi) {
throw new Error("Extensions using proposed API (enableProposedApi: true) can't be published to the Marketplace");
}
Expand Down

0 comments on commit ecab6bf

Please sign in to comment.