File tree Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -18,17 +18,23 @@ export class Cp {
18
18
* @param {string } containerName - The name of the container in the pod to exec the command inside.
19
19
* @param {string } srcPath - The source path in the pod
20
20
* @param {string } tgtPath - The target path in local
21
+ * @param {string } cwd - The directory that is used as the parent in the pod when downloading
21
22
*/
22
23
public async cpFromPod (
23
24
namespace : string ,
24
25
podName : string ,
25
26
containerName : string ,
26
27
srcPath : string ,
27
28
tgtPath : string ,
29
+ cwd ?: string ,
28
30
) : Promise < void > {
29
31
const tmpFile = tmp . fileSync ( ) ;
30
32
const tmpFileName = tmpFile . name ;
31
- const command = [ 'tar' , 'zcf' , '-' , srcPath ] ;
33
+ const command = [ 'tar' , 'zcf' , '-' ] ;
34
+ if ( cwd ) {
35
+ command . push ( '-C' , cwd ) ;
36
+ }
37
+ command . push ( srcPath ) ;
32
38
const writerStream = fs . createWriteStream ( tmpFileName ) ;
33
39
const errStream = new WritableStreamBuffer ( ) ;
34
40
this . execInstance . exec (
You can’t perform that action at this time.
0 commit comments