@@ -37,11 +37,13 @@ const MinimatchOptions: minimatch.IOptions = { dot: true };
37
37
38
38
export interface IInMemoryFile {
39
39
path : string ;
40
+ mode ?: number ;
40
41
readonly contents : Buffer | string ;
41
42
}
42
43
43
44
export interface ILocalFile {
44
45
path : string ;
46
+ mode ?: number ;
45
47
readonly localPath : string ;
46
48
}
47
49
@@ -208,7 +210,7 @@ function isHostTrusted(url: url.UrlWithStringQuery): boolean {
208
210
return TrustedSVGSources . indexOf ( url . host . toLowerCase ( ) ) > - 1 || isGitHubBadge ( url . href ) ;
209
211
}
210
212
211
- class ManifestProcessor extends BaseProcessor {
213
+ export class ManifestProcessor extends BaseProcessor {
212
214
constructor ( manifest : Manifest ) {
213
215
super ( manifest ) ;
214
216
@@ -274,6 +276,18 @@ class ManifestProcessor extends BaseProcessor {
274
276
}
275
277
}
276
278
279
+ async onFile ( file : IFile ) : Promise < IFile > {
280
+ const path = util . normalize ( file . path ) ;
281
+
282
+ if ( ! / ^ e x t e n s i o n \/ p a c k a g e .j s o n $ / i. test ( path ) ) {
283
+ return Promise . resolve ( file ) ;
284
+ }
285
+
286
+ // Ensure that package.json is writable as VS Code needs to
287
+ // store metadata in the extracted file.
288
+ return { ...file , mode : 0o100644 } ;
289
+ }
290
+
277
291
async onEnd ( ) : Promise < void > {
278
292
if ( typeof this . manifest . extensionKind === 'string' ) {
279
293
util . log . warn (
@@ -1104,8 +1118,10 @@ function writeVsix(files: IFile[], packagePath: string): Promise<void> {
1104
1118
const zip = new yazl . ZipFile ( ) ;
1105
1119
files . forEach ( f =>
1106
1120
isInMemoryFile ( f )
1107
- ? zip . addBuffer ( typeof f . contents === 'string' ? Buffer . from ( f . contents , 'utf8' ) : f . contents , f . path )
1108
- : zip . addFile ( f . localPath , f . path )
1121
+ ? zip . addBuffer ( typeof f . contents === 'string' ? Buffer . from ( f . contents , 'utf8' ) : f . contents , f . path , {
1122
+ mode : f . mode ,
1123
+ } )
1124
+ : zip . addFile ( f . localPath , f . path , { mode : f . mode } )
1109
1125
) ;
1110
1126
zip . end ( ) ;
1111
1127
0 commit comments