ssh2-scp 1.0.2 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/ssh-fs.cjs +5 -5
- package/dist/esm/ssh-fs.d.ts +2 -2
- package/dist/esm/ssh-fs.js +5 -5
- package/dist/esm/transfer.d.ts +2 -2
- package/package.json +1 -1
package/dist/cjs/ssh-fs.cjs
CHANGED
|
@@ -277,23 +277,23 @@ class SshFs {
|
|
|
277
277
|
const fileSize = parseInt(fileSizeOutput.trim(), 10);
|
|
278
278
|
if (fileSize <= chunkSize) {
|
|
279
279
|
const output = await this.runCmd(`cat "${remotePath}"`);
|
|
280
|
-
return
|
|
280
|
+
return output;
|
|
281
281
|
}
|
|
282
282
|
const chunks = [];
|
|
283
283
|
for (let offset = 0; offset < fileSize; offset += chunkSize) {
|
|
284
284
|
const cmd = `dd if="${remotePath}" bs=1K skip=${Math.floor(offset / 1024)} count=${Math.ceil(chunkSize / 1024)} 2>/dev/null`;
|
|
285
285
|
const chunkOutput = await this.runCmd(cmd);
|
|
286
286
|
if (chunkOutput) {
|
|
287
|
-
chunks.push(
|
|
287
|
+
chunks.push(chunkOutput);
|
|
288
288
|
}
|
|
289
289
|
}
|
|
290
|
-
return
|
|
290
|
+
return chunks.join("");
|
|
291
291
|
}
|
|
292
292
|
async writeFile(remotePath, str, mode, _options) {
|
|
293
|
-
const data =
|
|
293
|
+
const data = Buffer.from(str);
|
|
294
294
|
const sizeThreshold = 64 * 1024;
|
|
295
295
|
if (data.length <= sizeThreshold) {
|
|
296
|
-
const escapedContent =
|
|
296
|
+
const escapedContent = str.replace(/'/g, "'\\''");
|
|
297
297
|
const cmd = `printf '%s' '${escapedContent}' > "${remotePath}"`;
|
|
298
298
|
await this.runCmd(cmd);
|
|
299
299
|
} else {
|
package/dist/esm/ssh-fs.d.ts
CHANGED
|
@@ -53,8 +53,8 @@ export declare class SshFs {
|
|
|
53
53
|
rm(remotePath: string): Promise<string>;
|
|
54
54
|
readFile(remotePath: string, options?: {
|
|
55
55
|
chunkSize?: number;
|
|
56
|
-
}): Promise<
|
|
57
|
-
writeFile(remotePath: string, str:
|
|
56
|
+
}): Promise<string>;
|
|
57
|
+
writeFile(remotePath: string, str: string, mode?: number, _options?: {
|
|
58
58
|
chunkSize?: number;
|
|
59
59
|
}): Promise<void>;
|
|
60
60
|
}
|
package/dist/esm/ssh-fs.js
CHANGED
|
@@ -275,23 +275,23 @@ class SshFs {
|
|
|
275
275
|
const fileSize = parseInt(fileSizeOutput.trim(), 10);
|
|
276
276
|
if (fileSize <= chunkSize) {
|
|
277
277
|
const output = await this.runCmd(`cat "${remotePath}"`);
|
|
278
|
-
return
|
|
278
|
+
return output;
|
|
279
279
|
}
|
|
280
280
|
const chunks = [];
|
|
281
281
|
for (let offset = 0; offset < fileSize; offset += chunkSize) {
|
|
282
282
|
const cmd = `dd if="${remotePath}" bs=1K skip=${Math.floor(offset / 1024)} count=${Math.ceil(chunkSize / 1024)} 2>/dev/null`;
|
|
283
283
|
const chunkOutput = await this.runCmd(cmd);
|
|
284
284
|
if (chunkOutput) {
|
|
285
|
-
chunks.push(
|
|
285
|
+
chunks.push(chunkOutput);
|
|
286
286
|
}
|
|
287
287
|
}
|
|
288
|
-
return
|
|
288
|
+
return chunks.join("");
|
|
289
289
|
}
|
|
290
290
|
async writeFile(remotePath, str, mode, _options) {
|
|
291
|
-
const data =
|
|
291
|
+
const data = Buffer.from(str);
|
|
292
292
|
const sizeThreshold = 64 * 1024;
|
|
293
293
|
if (data.length <= sizeThreshold) {
|
|
294
|
-
const escapedContent =
|
|
294
|
+
const escapedContent = str.replace(/'/g, "'\\''");
|
|
295
295
|
const cmd = `printf '%s' '${escapedContent}' > "${remotePath}"`;
|
|
296
296
|
await this.runCmd(cmd);
|
|
297
297
|
} else {
|
package/dist/esm/transfer.d.ts
CHANGED
|
@@ -51,8 +51,8 @@ declare class SshFs {
|
|
|
51
51
|
rm(remotePath: string): Promise<string>;
|
|
52
52
|
readFile(remotePath: string, options?: {
|
|
53
53
|
chunkSize?: number;
|
|
54
|
-
}): Promise<
|
|
55
|
-
writeFile(remotePath: string, str:
|
|
54
|
+
}): Promise<string>;
|
|
55
|
+
writeFile(remotePath: string, str: string, mode?: number, _options?: {
|
|
56
56
|
chunkSize?: number;
|
|
57
57
|
}): Promise<void>;
|
|
58
58
|
}
|