ssh2-scp 3.0.1 → 3.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.
@@ -16,6 +16,9 @@ class SshFs {
16
16
  getExecOpts() {
17
17
  return {};
18
18
  }
19
+ maskMode(mode) {
20
+ return mode & 4095;
21
+ }
19
22
  getMonthIndex(month) {
20
23
  const months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
21
24
  return months.indexOf(month);
@@ -181,7 +184,7 @@ class SshFs {
181
184
  return this.listFiles(remotePath);
182
185
  }
183
186
  async mkdir(remotePath, options = {}) {
184
- const cmd = options.mode ? `mkdir -m ${options.mode.toString(8)} -p "${remotePath}"` : `mkdir -p "${remotePath}"`;
187
+ const cmd = options.mode ? `mkdir -m ${this.maskMode(options.mode).toString(8)} -p "${remotePath}"` : `mkdir -p "${remotePath}"`;
185
188
  return this.runCmd(cmd);
186
189
  }
187
190
  async stat(remotePath) {
@@ -276,7 +279,7 @@ class SshFs {
276
279
  };
277
280
  }
278
281
  chmod(remotePath, mode) {
279
- return this.runCmd(`chmod ${mode.toString(8)} "${remotePath}"`);
282
+ return this.runCmd(`chmod ${this.maskMode(mode).toString(8)} "${remotePath}"`);
280
283
  }
281
284
  rename(remotePath, remotePathNew) {
282
285
  return this.runCmd(`mv "${remotePath}" "${remotePathNew}"`);
@@ -336,7 +339,7 @@ class SshFs {
336
339
  }
337
340
  }
338
341
  if (mode) {
339
- await this.runCmd(`chmod ${mode.toString(8)} "${remotePath}"`);
342
+ await this.runCmd(`chmod ${this.maskMode(mode).toString(8)} "${remotePath}"`);
340
343
  }
341
344
  }
342
345
  }
@@ -27,6 +27,7 @@ export declare class SshFs {
27
27
  constructor(session: Client, _options?: SshFsOptions);
28
28
  private detectChunkSize;
29
29
  private getExecOpts;
30
+ private maskMode;
30
31
  private getMonthIndex;
31
32
  private runCmd;
32
33
  private rmFolderCmd;
@@ -14,6 +14,9 @@ class SshFs {
14
14
  getExecOpts() {
15
15
  return {};
16
16
  }
17
+ maskMode(mode) {
18
+ return mode & 4095;
19
+ }
17
20
  getMonthIndex(month) {
18
21
  const months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
19
22
  return months.indexOf(month);
@@ -179,7 +182,7 @@ class SshFs {
179
182
  return this.listFiles(remotePath);
180
183
  }
181
184
  async mkdir(remotePath, options = {}) {
182
- const cmd = options.mode ? `mkdir -m ${options.mode.toString(8)} -p "${remotePath}"` : `mkdir -p "${remotePath}"`;
185
+ const cmd = options.mode ? `mkdir -m ${this.maskMode(options.mode).toString(8)} -p "${remotePath}"` : `mkdir -p "${remotePath}"`;
183
186
  return this.runCmd(cmd);
184
187
  }
185
188
  async stat(remotePath) {
@@ -274,7 +277,7 @@ class SshFs {
274
277
  };
275
278
  }
276
279
  chmod(remotePath, mode) {
277
- return this.runCmd(`chmod ${mode.toString(8)} "${remotePath}"`);
280
+ return this.runCmd(`chmod ${this.maskMode(mode).toString(8)} "${remotePath}"`);
278
281
  }
279
282
  rename(remotePath, remotePathNew) {
280
283
  return this.runCmd(`mv "${remotePath}" "${remotePathNew}"`);
@@ -334,7 +337,7 @@ class SshFs {
334
337
  }
335
338
  }
336
339
  if (mode) {
337
- await this.runCmd(`chmod ${mode.toString(8)} "${remotePath}"`);
340
+ await this.runCmd(`chmod ${this.maskMode(mode).toString(8)} "${remotePath}"`);
338
341
  }
339
342
  }
340
343
  }
@@ -23,6 +23,7 @@ declare class SshFs {
23
23
  constructor(session: Client, _options?: SshFsOptions);
24
24
  private detectChunkSize;
25
25
  private getExecOpts;
26
+ private maskMode;
26
27
  private getMonthIndex;
27
28
  private runCmd;
28
29
  private rmFolderCmd;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ssh2-scp",
3
- "version": "3.0.1",
3
+ "version": "3.1.0",
4
4
  "description": "Remote file system operations over SSH2 session without SFTP",
5
5
  "scripts": {
6
6
  "build": "npm run build:esm && npm run build:cjs",