From 955e3df4d39e1e4bd81cc70637117ca70716a668 Mon Sep 17 00:00:00 2001 From: James Date: Sat, 30 Nov 2019 14:06:59 -0500 Subject: [PATCH] fixes #400 allow force to unpublish an extension --- src/main.ts | 3 ++- src/publish.ts | 12 +++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/main.ts b/src/main.ts index 3408d6f7..dcaf77cf 100644 --- a/src/main.ts +++ b/src/main.ts @@ -93,7 +93,8 @@ module.exports = function (argv: string[]): void { .command('unpublish []') .description('Unpublishes an extension. Example extension id: microsoft.csharp.') .option('-p, --pat ', 'Personal Access Token') - .action((id, { pat }) => main(unpublish({ id, pat }))); + .option('-f, --force', 'Forces Unpublished Extension') + .action((id, { pat, force }) => main(unpublish({ id, pat, force }))); program .command('ls-publishers') diff --git a/src/publish.ts b/src/publish.ts index 09660803..ead4625a 100644 --- a/src/publish.ts +++ b/src/publish.ts @@ -92,6 +92,7 @@ export interface IPublishOptions { commitMessage?: string; cwd?: string; pat?: string; + force?: boolean; baseContentUrl?: string; baseImagesUrl?: string; useYarn?: boolean; @@ -187,14 +188,19 @@ export function unpublish(options: IUnpublishOptions = {}): Promise { } return promise.then(({ publisher, name }) => { + const fullName = `${publisher}.${name}`; const pat = options.pat ? Promise.resolve(options.pat) : getPublisher(publisher).then(p => p.pat); - return read(`This will FOREVER delete '${fullName}'! Are you sure? [y/N] `) - .then(answer => /^y$/i.test(answer) ? null : Promise.reject('Aborted')) - .then(() => pat) + const force = options.force; + + return (!force ? ( + read(`This will FOREVER delete '${fullName}'! Are you sure? [y/N] `) + .then(answer => /^y$/i.test(answer) ? pat : Promise.reject('Aborted')) + //.then(() => pat) + ) : pat) .then(getGalleryAPI) .then(api => api.deleteExtension(publisher, name)) .then(() => log.done(`Deleted extension: ${fullName}!`));