ssh-client-wrapper 1.5.4 → 1.6.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/lib/sshExec.js CHANGED
@@ -35,7 +35,7 @@ async function sshExec(hostInfo, cmd, outputCallback) {
35
35
  debug(`${cmd} not found but ignored`);
36
36
  return e.rt;
37
37
  }
38
- throw e;
38
+ return e.rt;
39
39
  }
40
40
  }
41
41
 
@@ -234,12 +234,12 @@ async function ls(hostInfo, target, lsOpt = []) {
234
234
  throw e;
235
235
  }
236
236
  }
237
-
238
- return outputArray
239
- .join("\n")
240
- .replace(/\n+/g, "\n")
241
- .replace(/\n$/, "")
242
- .split("\n");
237
+ return outputArray.length === 0 ? []
238
+ : outputArray
239
+ .join("\n")
240
+ .replace(/\n+/g, "\n")
241
+ .replace(/\n$/, "")
242
+ .split("\n");
243
243
  }
244
244
 
245
245
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ssh-client-wrapper",
3
- "version": "1.5.4",
3
+ "version": "1.6.0",
4
4
  "description": "wrapper library for open ssh client and rsync",
5
5
  "keywords": [
6
6
  "ssh",
package/test/sshExec.js CHANGED
@@ -18,7 +18,7 @@ const { sshExec, canConnect, disconnect, ls } = require("../lib/sshExec.js");
18
18
 
19
19
  //test helpers
20
20
  const hostInfo = require("./util/hostInfo.js");
21
- const { clearRemoteTestFiles, createRemoteFiles, nonExisting, remoteRoot } = require("./util/testFiles.js");
21
+ const { clearRemoteTestFiles, createRemoteFiles, nonExisting, remoteRoot, remoteEmptyDir } = require("./util/testFiles.js");
22
22
 
23
23
 
24
24
  describe("test for ssh execution", function() {
@@ -129,5 +129,8 @@ describe("test for ssh execution", function() {
129
129
  return path.posix.join(remoteRoot, "hoge", e);
130
130
  }));
131
131
  });
132
+ it("should return empty array if specified target is empty directory", async ()=>{
133
+ expect(await ls(hostInfo, remoteEmptyDir)).to.be.an("array").that.is.empty;
134
+ });
132
135
  });
133
136
  });