File tree 3 files changed +6
-15
lines changed
3 files changed +6
-15
lines changed Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ export type Commit = {
23
23
24
24
export type ExecOpts = {
25
25
allowAllExitCodes ?: boolean ,
26
+ encoding ?: 'utf8' | 'base64'
26
27
}
27
28
28
29
export class GitCommandManager {
@@ -282,9 +283,9 @@ export class GitCommandManager {
282
283
return output . stdout . trim ( )
283
284
}
284
285
285
- async showFileAtRef ( ref : string , path : string ) : Promise < string > {
286
+ async showFileAtRefBase64 ( ref : string , path : string ) : Promise < string > {
286
287
const args = [ 'show' , `${ ref } :${ path } ` ]
287
- const output = await this . exec ( args )
288
+ const output = await this . exec ( args , { encoding : 'base64' } )
288
289
return output . stdout . trim ( )
289
290
}
290
291
@@ -376,10 +377,10 @@ export class GitCommandManager {
376
377
ignoreReturnCode : opts . allowAllExitCodes ?? false ,
377
378
listeners : {
378
379
stdout : ( data : Buffer ) => {
379
- stdout . push ( data . toString ( ) )
380
+ stdout . push ( data . toString ( opts . encoding ?? 'utf8' ) )
380
381
} ,
381
382
stderr : ( data : Buffer ) => {
382
- stderr . push ( data . toString ( ) )
383
+ stderr . push ( data . toString ( opts . encoding ?? 'utf8' ) )
383
384
}
384
385
}
385
386
}
Original file line number Diff line number Diff line change @@ -275,7 +275,7 @@ export class GitHubHelper {
275
275
const { data : blob } = await blobCreationLimit ( ( ) =>
276
276
this . octokit . rest . git . createBlob ( {
277
277
...repository ,
278
- content : git . showFileAtRef ( commit . sha , path ) ,
278
+ content : git . showFileAtRefBase64 ( commit . sha , path ) ,
279
279
encoding : 'base64'
280
280
} )
281
281
)
Original file line number Diff line number Diff line change @@ -126,16 +126,6 @@ export function readFile(path: string): string {
126
126
return fs . readFileSync ( path , 'utf-8' )
127
127
}
128
128
129
- export function readFileBase64 ( pathParts : string [ ] ) : string {
130
- const resolvedPath = path . resolve ( ...pathParts )
131
- if ( fs . lstatSync ( resolvedPath ) . isSymbolicLink ( ) ) {
132
- return fs
133
- . readlinkSync ( resolvedPath , { encoding : 'buffer' } )
134
- . toString ( 'base64' )
135
- }
136
- return fs . readFileSync ( resolvedPath ) . toString ( 'base64' )
137
- }
138
-
139
129
/* eslint-disable @typescript-eslint/no-explicit-any */
140
130
function hasErrorCode ( error : any ) : error is { code : string } {
141
131
return typeof ( error && error . code ) === 'string'
You can’t perform that action at this time.
0 commit comments