1- import fs from 'node:fs' ;
1+ import fs , { rmSync } from 'node:fs' ;
22import { WritableStreamBuffer } from 'stream-buffers' ;
3- import * as tar from 'tar' ;
3+ import tar from 'tar-fs ' ;
44import tmp from 'tmp-promise' ;
5+ import path from 'node:path' ;
56
67import { KubeConfig } from './config.js' ;
78import { Exec } from './exec.js' ;
9+ import { getServers } from 'node:dns' ;
810
911export class Cp {
1012 public execInstance : Exec ;
@@ -29,7 +31,7 @@ export class Cp {
2931 const tmpFile = tmp . fileSync ( ) ;
3032 const tmpFileName = tmpFile . name ;
3133 const command = [ 'tar' , 'zcf' , '-' , srcPath ] ;
32- const writerStream = fs . createWriteStream ( tmpFileName ) ;
34+ const writerStream = tar . extract ( tgtPath ) ;
3335 const errStream = new WritableStreamBuffer ( ) ;
3436 this . execInstance . exec (
3537 namespace ,
@@ -44,10 +46,6 @@ export class Cp {
4446 if ( errStream . size ( ) ) {
4547 throw new Error ( `Error from cpFromPod - details: \n ${ errStream . getContentsAsString ( ) } ` ) ;
4648 }
47- await tar . x ( {
48- file : tmpFileName ,
49- cwd : tgtPath ,
50- } ) ;
5149 } ,
5250 ) ;
5351 }
@@ -66,16 +64,8 @@ export class Cp {
6664 srcPath : string ,
6765 tgtPath : string ,
6866 ) : Promise < void > {
69- const tmpFile = tmp . fileSync ( ) ;
70- const tmpFileName = tmpFile . name ;
7167 const command = [ 'tar' , 'xf' , '-' , '-C' , tgtPath ] ;
72- await tar . c (
73- {
74- file : tmpFile . name ,
75- } ,
76- [ srcPath ] ,
77- ) ;
78- const readStream = fs . createReadStream ( tmpFileName ) ;
68+ const readStream = tar . pack ( srcPath ) ;
7969 const errStream = new WritableStreamBuffer ( ) ;
8070 this . execInstance . exec (
8171 namespace ,
0 commit comments