-
Notifications
You must be signed in to change notification settings - Fork 544
Move to tar-fs. #2402
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move to tar-fs. #2402
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,12 @@ | ||
import fs from 'node:fs'; | ||
import fs, { rmSync } from 'node:fs'; | ||
Check failure on line 1 in src/cp.ts
|
||
import { WritableStreamBuffer } from 'stream-buffers'; | ||
import * as tar from 'tar'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There are some linter errors in this file. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed. |
||
import tar from 'tar-fs'; | ||
import tmp from 'tmp-promise'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry for the back and forth - I think this is the only use of this dependency in the project. If it's removed here, it can be removed from package.json and package-lock.json too. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done (and removed |
||
import path from 'node:path'; | ||
Check failure on line 5 in src/cp.ts
|
||
|
||
import { KubeConfig } from './config.js'; | ||
import { Exec } from './exec.js'; | ||
import { getServers } from 'node:dns'; | ||
Check failure on line 9 in src/cp.ts
|
||
|
||
export class Cp { | ||
public execInstance: Exec; | ||
|
@@ -27,9 +29,9 @@ | |
tgtPath: string, | ||
): Promise<void> { | ||
const tmpFile = tmp.fileSync(); | ||
const tmpFileName = tmpFile.name; | ||
Check failure on line 32 in src/cp.ts
|
||
const command = ['tar', 'zcf', '-', srcPath]; | ||
const writerStream = fs.createWriteStream(tmpFileName); | ||
const writerStream = tar.extract(tgtPath); | ||
const errStream = new WritableStreamBuffer(); | ||
this.execInstance.exec( | ||
namespace, | ||
|
@@ -44,10 +46,6 @@ | |
if (errStream.size()) { | ||
throw new Error(`Error from cpFromPod - details: \n ${errStream.getContentsAsString()}`); | ||
} | ||
await tar.x({ | ||
file: tmpFileName, | ||
cwd: tgtPath, | ||
}); | ||
}, | ||
); | ||
} | ||
|
@@ -66,16 +64,8 @@ | |
srcPath: string, | ||
tgtPath: string, | ||
): Promise<void> { | ||
const tmpFile = tmp.fileSync(); | ||
const tmpFileName = tmpFile.name; | ||
const command = ['tar', 'xf', '-', '-C', tgtPath]; | ||
await tar.c( | ||
{ | ||
file: tmpFile.name, | ||
}, | ||
[srcPath], | ||
); | ||
const readStream = fs.createReadStream(tmpFileName); | ||
const readStream = tar.pack(srcPath); | ||
const errStream = new WritableStreamBuffer(); | ||
this.execInstance.exec( | ||
namespace, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tar
should be removed from this file andpackage-lock.json
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed.