@@ -57,6 +57,7 @@ export interface IPublishOptions {
57
57
readonly preRelease ?: boolean ;
58
58
readonly allowStarActivation ?: boolean ;
59
59
readonly allowMissingRepository ?: boolean ;
60
+ readonly skipDuplicate ?: boolean ;
60
61
}
61
62
62
63
export async function publish ( options : IPublishOptions = { } ) : Promise < any > {
@@ -123,6 +124,7 @@ export interface IInternalPublishOptions {
123
124
readonly target ?: string ;
124
125
readonly pat ?: string ;
125
126
readonly noVerify ?: boolean ;
127
+ readonly skipDuplicate ?: boolean ;
126
128
}
127
129
128
130
async function _publish ( packagePath : string , manifest : Manifest , options : IInternalPublishOptions ) {
@@ -170,6 +172,10 @@ async function _publish(packagePath: string, manifest: Manifest, options: IInter
170
172
const sameVersion = extension . versions . filter ( v => v . version === manifest . version ) ;
171
173
172
174
if ( sameVersion . length > 0 ) {
175
+ if ( options . skipDuplicate ) {
176
+ log . done ( `Version ${ manifest . version } is already published. Skipping publish.` ) ;
177
+ return ;
178
+ }
173
179
if ( ! options . target ) {
174
180
throw new Error ( `${ description } already exists.` ) ;
175
181
}
@@ -187,7 +193,12 @@ async function _publish(packagePath: string, manifest: Manifest, options: IInter
187
193
await api . updateExtension ( undefined , packageStream , manifest . publisher , manifest . name ) ;
188
194
} catch ( err : any ) {
189
195
if ( err . statusCode === 409 ) {
190
- throw new Error ( `${ description } already exists.` ) ;
196
+ if ( options . skipDuplicate ) {
197
+ log . done ( `Version ${ manifest . version } is already published. Skipping publish.` ) ;
198
+ return ;
199
+ } else {
200
+ throw new Error ( `${ description } already exists.` ) ;
201
+ }
191
202
} else {
192
203
throw err ;
193
204
}
0 commit comments