ssh-client-wrapper 1.8.2 → 2.0.1
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/.github/workflows/coverage_report.yml +22 -0
- package/.github/workflows/{npm-publish.yml → npm_publish.yml} +2 -2
- package/.github/workflows/run_test.yml +6 -0
- package/lib/fork.js +36 -23
- package/lib/index.js +52 -35
- package/lib/rsyncExec.js +8 -6
- package/lib/sshExec.js +37 -68
- package/lib/util.js +57 -3
- package/package.json +3 -2
- package/test/interface.js +180 -0
- package/test/rsyncExec.js +67 -67
- package/test/sshExec.js +12 -9
package/test/rsyncExec.js
CHANGED
|
@@ -50,7 +50,7 @@ describe("test rsync exec", function() {
|
|
|
50
50
|
};
|
|
51
51
|
let remoteHome;
|
|
52
52
|
before(async ()=>{
|
|
53
|
-
await sshExec(hostInfo, "pwd", (data)=>{
|
|
53
|
+
await sshExec(hostInfo, "pwd", 0, (data)=>{
|
|
54
54
|
remoteHome = data.trim();
|
|
55
55
|
});
|
|
56
56
|
});
|
|
@@ -71,57 +71,57 @@ describe("test rsync exec", function() {
|
|
|
71
71
|
describe("#send", async ()=>{
|
|
72
72
|
describe("send single file", ()=>{
|
|
73
73
|
it("should accept relative src file and relative dst dir name", async ()=>{
|
|
74
|
-
await send(hostInfo, [localFiles[0]], remoteEmptyDir);
|
|
74
|
+
await send(hostInfo, [localFiles[0]], remoteEmptyDir, [], 0);
|
|
75
75
|
|
|
76
|
-
await sshExec(hostInfo, `ls ${remoteEmptyDir}`, output);
|
|
76
|
+
await sshExec(hostInfo, `ls ${remoteEmptyDir}`, 0, output);
|
|
77
77
|
expect(formatLsOutput(rt)).to.have.members(["foo"]);
|
|
78
78
|
});
|
|
79
79
|
it("should accept absolute src file and relative dst dir name", async ()=>{
|
|
80
|
-
await send(hostInfo, [path.resolve(localFiles[3])], remoteEmptyDir);
|
|
80
|
+
await send(hostInfo, [path.resolve(localFiles[3])], remoteEmptyDir, [], 0);
|
|
81
81
|
|
|
82
|
-
await sshExec(hostInfo, `ls ${remoteEmptyDir}`, output);
|
|
82
|
+
await sshExec(hostInfo, `ls ${remoteEmptyDir}`, 0, output);
|
|
83
83
|
expect(formatLsOutput(rt)).to.have.members(["piyo"]);
|
|
84
84
|
});
|
|
85
85
|
it("should accept relative src file and absolute dst dir name", async ()=>{
|
|
86
|
-
await send(hostInfo, [localFiles[0]], `${path.posix.join(remoteHome, remoteEmptyDir)}
|
|
86
|
+
await send(hostInfo, [localFiles[0]], `${path.posix.join(remoteHome, remoteEmptyDir)}/`, [], 0);
|
|
87
87
|
|
|
88
|
-
await sshExec(hostInfo, `ls ${remoteEmptyDir}`, output);
|
|
88
|
+
await sshExec(hostInfo, `ls ${remoteEmptyDir}`, 0, output);
|
|
89
89
|
expect(formatLsOutput(rt)).to.have.members(["foo"]);
|
|
90
90
|
});
|
|
91
91
|
it("should accept absolute src file and absolute dst dir name", async ()=>{
|
|
92
|
-
await send(hostInfo, [path.resolve(localFiles[0])], path.posix.join(remoteHome, remoteEmptyDir));
|
|
92
|
+
await send(hostInfo, [path.resolve(localFiles[0])], path.posix.join(remoteHome, remoteEmptyDir), [], 0);
|
|
93
93
|
|
|
94
|
-
await sshExec(hostInfo, `ls ${remoteEmptyDir}`, output);
|
|
94
|
+
await sshExec(hostInfo, `ls ${remoteEmptyDir}`, 0, output);
|
|
95
95
|
expect(formatLsOutput(rt)).to.have.members(["foo"]);
|
|
96
96
|
});
|
|
97
97
|
it("should accept relative src file and relative dst file name", async ()=>{
|
|
98
|
-
await send(hostInfo, [localFiles[0]], path.posix.join(remoteEmptyDir, "hoge"));
|
|
98
|
+
await send(hostInfo, [localFiles[0]], path.posix.join(remoteEmptyDir, "hoge"), [], 0);
|
|
99
99
|
|
|
100
|
-
await sshExec(hostInfo, `ls ${path.posix.join(remoteEmptyDir, "hoge")}`, output);
|
|
100
|
+
await sshExec(hostInfo, `ls ${path.posix.join(remoteEmptyDir, "hoge")}`, 0, output);
|
|
101
101
|
expect(formatLsOutput(rt.map((e)=>{
|
|
102
102
|
return path.posix.basename(e);
|
|
103
103
|
}))).to.have.members(["hoge"]);
|
|
104
104
|
});
|
|
105
105
|
it("should accept absolute src file and relative dst file name", async ()=>{
|
|
106
|
-
await send(hostInfo, [path.resolve(localFiles[0])], path.posix.join(remoteEmptyDir, "hoge"));
|
|
106
|
+
await send(hostInfo, [path.resolve(localFiles[0])], path.posix.join(remoteEmptyDir, "hoge"), [], 0);
|
|
107
107
|
|
|
108
|
-
await sshExec(hostInfo, `ls ${path.posix.join(remoteEmptyDir, "hoge")}`, output);
|
|
108
|
+
await sshExec(hostInfo, `ls ${path.posix.join(remoteEmptyDir, "hoge")}`, 0, output);
|
|
109
109
|
expect(formatLsOutput(rt.map((e)=>{
|
|
110
110
|
return path.posix.basename(e);
|
|
111
111
|
}))).to.have.members(["hoge"]);
|
|
112
112
|
});
|
|
113
113
|
it("should accept relative src file and absolute dst file name", async ()=>{
|
|
114
|
-
await send(hostInfo, [localFiles[0]], path.posix.join(remoteHome, remoteEmptyDir, "hoge"));
|
|
114
|
+
await send(hostInfo, [localFiles[0]], path.posix.join(remoteHome, remoteEmptyDir, "hoge"), [], 0);
|
|
115
115
|
|
|
116
|
-
await sshExec(hostInfo, `ls ${path.posix.join(remoteEmptyDir, "hoge")}`, output);
|
|
116
|
+
await sshExec(hostInfo, `ls ${path.posix.join(remoteEmptyDir, "hoge")}`, 0, output);
|
|
117
117
|
expect(formatLsOutput(rt.map((e)=>{
|
|
118
118
|
return path.posix.basename(e);
|
|
119
119
|
}))).to.have.members(["hoge"]);
|
|
120
120
|
});
|
|
121
121
|
it("should accept absolute src file and absolute dst file name", async ()=>{
|
|
122
|
-
await send(hostInfo, [path.resolve(localFiles[0])], path.posix.join(remoteHome, remoteEmptyDir, "hoge"));
|
|
122
|
+
await send(hostInfo, [path.resolve(localFiles[0])], path.posix.join(remoteHome, remoteEmptyDir, "hoge"), [], 0);
|
|
123
123
|
|
|
124
|
-
await sshExec(hostInfo, `ls ${path.posix.join(remoteEmptyDir, "hoge")}`, output);
|
|
124
|
+
await sshExec(hostInfo, `ls ${path.posix.join(remoteEmptyDir, "hoge")}`, 0, output);
|
|
125
125
|
expect(formatLsOutput(rt.map((e)=>{
|
|
126
126
|
return path.posix.basename(e);
|
|
127
127
|
}))).to.have.members(["hoge"]);
|
|
@@ -129,8 +129,8 @@ describe("test rsync exec", function() {
|
|
|
129
129
|
|
|
130
130
|
it("should overwrite existing file", async ()=>{
|
|
131
131
|
const target = path.posix.join(remoteEmptyDir, "hoge");
|
|
132
|
-
await send(hostInfo, [localFiles[0]], target);
|
|
133
|
-
await sshExec(hostInfo, `ls ${target}`, output);
|
|
132
|
+
await send(hostInfo, [localFiles[0]], target, [], 0);
|
|
133
|
+
await sshExec(hostInfo, `ls ${target}`, 0, output);
|
|
134
134
|
expect(formatLsOutput(rt.map((e)=>{
|
|
135
135
|
return path.posix.basename(e);
|
|
136
136
|
}))).to.have.members(["hoge"]);
|
|
@@ -139,168 +139,168 @@ describe("test rsync exec", function() {
|
|
|
139
139
|
const time = new Date();
|
|
140
140
|
time.setMinutes(time.getMinutes() + 3);
|
|
141
141
|
await fs.utimes(localFiles[1], time, time);
|
|
142
|
-
await send(hostInfo, [localFiles[1]], target);
|
|
143
|
-
await sshExec(hostInfo, `ls ${target}`, output);
|
|
142
|
+
await send(hostInfo, [localFiles[1]], target, [], 0);
|
|
143
|
+
await sshExec(hostInfo, `ls ${target}`, 0, output);
|
|
144
144
|
expect(formatLsOutput(rt.map((e)=>{
|
|
145
145
|
return path.posix.basename(e);
|
|
146
146
|
}))).to.have.members(["hoge"]);
|
|
147
147
|
|
|
148
148
|
rt.splice(0, rt.length);
|
|
149
|
-
await sshExec(hostInfo, `cat ${target}`, output);
|
|
149
|
+
await sshExec(hostInfo, `cat ${target}`, 0, output);
|
|
150
150
|
expect(formatLsOutput(rt)).to.have.members(["ARssh_testLocalDir/bar"]);
|
|
151
151
|
});
|
|
152
152
|
});
|
|
153
153
|
describe("send directory tree", ()=>{
|
|
154
154
|
it("should accept relative src dirname and relative dst dirname", async ()=>{
|
|
155
|
-
await send(hostInfo, [localRoot], remoteEmptyDir);
|
|
155
|
+
await send(hostInfo, [localRoot], remoteEmptyDir, [], 0);
|
|
156
156
|
|
|
157
|
-
await sshExec(hostInfo, `ls ${path.posix.join(remoteEmptyDir, localRoot)}`, output);
|
|
157
|
+
await sshExec(hostInfo, `ls ${path.posix.join(remoteEmptyDir, localRoot)}`, 0, output);
|
|
158
158
|
expect(formatLsOutput(rt)).to.have.members(["foo", "bar", "baz", "hoge", "huga"]);
|
|
159
159
|
|
|
160
160
|
rt.splice(0, rt.length);
|
|
161
|
-
await sshExec(hostInfo, `ls ${path.posix.join(remoteEmptyDir, localRoot, "hoge")}`, output);
|
|
161
|
+
await sshExec(hostInfo, `ls ${path.posix.join(remoteEmptyDir, localRoot, "hoge")}`, 0, output);
|
|
162
162
|
expect(formatLsOutput(rt)).to.have.members(["piyo", "puyo", "poyo"]);
|
|
163
163
|
});
|
|
164
164
|
it("should accept absolute src dirname and relative dst dirname", async ()=>{
|
|
165
|
-
await send(hostInfo, [path.resolve(localRoot)], remoteEmptyDir);
|
|
165
|
+
await send(hostInfo, [path.resolve(localRoot)], remoteEmptyDir, [], 0);
|
|
166
166
|
|
|
167
|
-
await sshExec(hostInfo, `ls ${path.posix.join(remoteEmptyDir, localRoot)}`, output);
|
|
167
|
+
await sshExec(hostInfo, `ls ${path.posix.join(remoteEmptyDir, localRoot)}`, 0, output);
|
|
168
168
|
expect(formatLsOutput(rt)).to.have.members(["foo", "bar", "baz", "hoge", "huga"]);
|
|
169
169
|
|
|
170
170
|
rt.splice(0, rt.length);
|
|
171
|
-
await sshExec(hostInfo, `ls ${path.posix.join(remoteEmptyDir, localRoot, "hoge")}`, output);
|
|
171
|
+
await sshExec(hostInfo, `ls ${path.posix.join(remoteEmptyDir, localRoot, "hoge")}`, 0, output);
|
|
172
172
|
expect(formatLsOutput(rt)).to.have.members(["piyo", "puyo", "poyo"]);
|
|
173
173
|
});
|
|
174
174
|
it("should accept relative src dirname and absolute dst dirname", async ()=>{
|
|
175
|
-
await send(hostInfo, [localRoot], path.posix.join(remoteHome, remoteEmptyDir));
|
|
175
|
+
await send(hostInfo, [localRoot], path.posix.join(remoteHome, remoteEmptyDir), [], 0);
|
|
176
176
|
|
|
177
|
-
await sshExec(hostInfo, `ls ${path.posix.join(remoteEmptyDir, localRoot)}`, output);
|
|
177
|
+
await sshExec(hostInfo, `ls ${path.posix.join(remoteEmptyDir, localRoot)}`, 0, output);
|
|
178
178
|
expect(formatLsOutput(rt)).to.have.members(["foo", "bar", "baz", "hoge", "huga"]);
|
|
179
179
|
|
|
180
180
|
rt.splice(0, rt.length);
|
|
181
|
-
await sshExec(hostInfo, `ls ${path.posix.join(remoteEmptyDir, localRoot, "hoge")}`, output);
|
|
181
|
+
await sshExec(hostInfo, `ls ${path.posix.join(remoteEmptyDir, localRoot, "hoge")}`, 0, output);
|
|
182
182
|
expect(formatLsOutput(rt)).to.have.members(["piyo", "puyo", "poyo"]);
|
|
183
183
|
});
|
|
184
184
|
it("should accept absolute src dirname and absolute dst dirname", async ()=>{
|
|
185
|
-
await send(hostInfo, [path.resolve(localRoot)], path.posix.join(remoteHome, remoteEmptyDir));
|
|
185
|
+
await send(hostInfo, [path.resolve(localRoot)], path.posix.join(remoteHome, remoteEmptyDir), [], 0);
|
|
186
186
|
|
|
187
|
-
await sshExec(hostInfo, `ls ${path.posix.join(remoteEmptyDir, localRoot)}`, output);
|
|
187
|
+
await sshExec(hostInfo, `ls ${path.posix.join(remoteEmptyDir, localRoot)}`, 0, output);
|
|
188
188
|
expect(formatLsOutput(rt)).to.have.members(["foo", "bar", "baz", "hoge", "huga"]);
|
|
189
189
|
|
|
190
190
|
rt.splice(0, rt.length);
|
|
191
|
-
await sshExec(hostInfo, `ls ${path.posix.join(remoteEmptyDir, localRoot, "hoge")}`, output);
|
|
191
|
+
await sshExec(hostInfo, `ls ${path.posix.join(remoteEmptyDir, localRoot, "hoge")}`, 0, output);
|
|
192
192
|
expect(formatLsOutput(rt)).to.have.members(["piyo", "puyo", "poyo"]);
|
|
193
193
|
});
|
|
194
194
|
//only option need special treatment in rsyncExec. it's hard to set in WHEEL
|
|
195
195
|
it.skip("[not implemented] should send directory tree if only filter matched", async ()=>{
|
|
196
|
-
await send(hostInfo, [localRoot], remoteEmptyDir, [`--include=${localRoot}`, `--include=${localRoot}/ba*`, `--include=${localRoot}/hoge/*`, "--exclude=*"]);
|
|
196
|
+
await send(hostInfo, [localRoot], remoteEmptyDir, [`--include=${localRoot}`, `--include=${localRoot}/ba*`, `--include=${localRoot}/hoge/*`, "--exclude=*"], [], 0);
|
|
197
197
|
|
|
198
|
-
await sshExec(hostInfo, `ls ${path.posix.join(remoteEmptyDir, localRoot)}`, output);
|
|
198
|
+
await sshExec(hostInfo, `ls ${path.posix.join(remoteEmptyDir, localRoot)}`, 0, output);
|
|
199
199
|
expect(formatLsOutput(rt)).to.have.members(["hoge", "bar", "baz"]);
|
|
200
200
|
|
|
201
201
|
rt.splice(0, rt.length);
|
|
202
|
-
await sshExec(hostInfo, `ls ${path.posix.join(remoteEmptyDir, localRoot, "hoge")}`, output);
|
|
202
|
+
await sshExec(hostInfo, `ls ${path.posix.join(remoteEmptyDir, localRoot, "hoge")}`, 0, output);
|
|
203
203
|
expect(formatLsOutput(rt)).to.have.members(["piyo", "puyo", "poyo"]);
|
|
204
204
|
});
|
|
205
205
|
it("should send directory tree if exclude filter not matched", async ()=>{
|
|
206
|
-
await send(hostInfo, [localRoot], remoteEmptyDir, ["--exclude=ba*", "--exclude=hoge*}"]);
|
|
206
|
+
await send(hostInfo, [localRoot], remoteEmptyDir, ["--exclude=ba*", "--exclude=hoge*}"], [], 0);
|
|
207
207
|
|
|
208
|
-
await sshExec(hostInfo, `ls ${path.posix.join(remoteEmptyDir, localRoot)}`, output);
|
|
208
|
+
await sshExec(hostInfo, `ls ${path.posix.join(remoteEmptyDir, localRoot)}`, 0, output);
|
|
209
209
|
expect(formatLsOutput(rt)).to.have.members(["foo", "hoge", "huga"]);
|
|
210
210
|
});
|
|
211
211
|
it.skip("[not implemented] should send directory tree if only filter matched but exclude filter not matched", async ()=>{
|
|
212
|
-
await send(hostInfo, [localRoot], remoteEmptyDir, "*/{ba*,hoge/*}", "**/poyo");
|
|
212
|
+
await send(hostInfo, [localRoot], remoteEmptyDir, "*/{ba*,hoge/*}", "**/poyo", [], 0);
|
|
213
213
|
|
|
214
|
-
await sshExec(hostInfo, `ls ${path.posix.join(remoteEmptyDir, localRoot)}`, output);
|
|
214
|
+
await sshExec(hostInfo, `ls ${path.posix.join(remoteEmptyDir, localRoot)}`, 0, output);
|
|
215
215
|
expect(formatLsOutput(rt)).to.have.members(["hoge", "bar", "baz"]);
|
|
216
216
|
|
|
217
217
|
rt.splice(0, rt.length);
|
|
218
|
-
await sshExec(hostInfo, `ls ${path.posix.join(remoteEmptyDir, localRoot, "hoge")}`, output);
|
|
218
|
+
await sshExec(hostInfo, `ls ${path.posix.join(remoteEmptyDir, localRoot, "hoge")}`, 0, output);
|
|
219
219
|
expect(formatLsOutput(rt)).to.have.members(["piyo", "puyo"]);
|
|
220
220
|
});
|
|
221
221
|
it("shoud not send empty directory with -m option", async ()=>{
|
|
222
|
-
await send(hostInfo, [localEmptyDir], remoteEmptyDir, ["-m"]);
|
|
222
|
+
await send(hostInfo, [localEmptyDir], remoteEmptyDir, ["-m"], [], 0);
|
|
223
223
|
|
|
224
|
-
await sshExec(hostInfo, `ls ${remoteEmptyDir}`, output);
|
|
224
|
+
await sshExec(hostInfo, `ls ${remoteEmptyDir}`, 0, output);
|
|
225
225
|
expect(rt).to.have.lengthOf(0);
|
|
226
226
|
});
|
|
227
227
|
it("should send files which match glob pattern", async ()=>{
|
|
228
|
-
await send(hostInfo, [path.join(localRoot, "b*")], remoteEmptyDir);
|
|
228
|
+
await send(hostInfo, [path.join(localRoot, "b*")], remoteEmptyDir, [], 0);
|
|
229
229
|
|
|
230
|
-
await sshExec(hostInfo, `ls ${remoteEmptyDir}`, output);
|
|
230
|
+
await sshExec(hostInfo, `ls ${remoteEmptyDir}`, 0, output);
|
|
231
231
|
expect(formatLsOutput(rt)).to.have.members(["bar", "baz"]);
|
|
232
232
|
});
|
|
233
233
|
});
|
|
234
234
|
describe("error case", ()=>{
|
|
235
235
|
it("should not send directory to existing file path", ()=>{
|
|
236
|
-
return expect(send(hostInfo, [localRoot], path.posix.join(remoteRoot, "foo"))).to.be.rejected;
|
|
236
|
+
return expect(send(hostInfo, [localRoot], path.posix.join(remoteRoot, "foo"), [], 0)).to.be.rejected;
|
|
237
237
|
});
|
|
238
238
|
});
|
|
239
239
|
});
|
|
240
240
|
describe("#recv", async ()=>{
|
|
241
241
|
describe("recieve single file", ()=>{
|
|
242
242
|
it("should accept relative src file and relative dst dir name", async ()=>{
|
|
243
|
-
await recv(hostInfo, [remoteFiles[3]], localEmptyDir);
|
|
243
|
+
await recv(hostInfo, [remoteFiles[3]], localEmptyDir, [], 0);
|
|
244
244
|
|
|
245
245
|
const rt2 = await fs.readdir(localEmptyDir);
|
|
246
246
|
expect(rt2).to.have.members(["piyo"]);
|
|
247
247
|
});
|
|
248
248
|
it("should accept absolute src file and relative dst dir name", async ()=>{
|
|
249
|
-
await recv(hostInfo, [path.posix.join(remoteHome, remoteFiles[3])], localEmptyDir);
|
|
249
|
+
await recv(hostInfo, [path.posix.join(remoteHome, remoteFiles[3])], localEmptyDir, [], 0);
|
|
250
250
|
|
|
251
251
|
const rt2 = await fs.readdir(localEmptyDir);
|
|
252
252
|
expect(rt2).to.have.members(["piyo"]);
|
|
253
253
|
});
|
|
254
254
|
it("should accept relative src file and absolute dst dir name", async ()=>{
|
|
255
|
-
await recv(hostInfo, [remoteFiles[3]], path.resolve(localEmptyDir));
|
|
255
|
+
await recv(hostInfo, [remoteFiles[3]], path.resolve(localEmptyDir), [], 0);
|
|
256
256
|
|
|
257
257
|
const rt2 = await fs.readdir(localEmptyDir);
|
|
258
258
|
expect(rt2).to.have.members(["piyo"]);
|
|
259
259
|
});
|
|
260
260
|
it("should accept absolute src file and absolute dst dir name", async ()=>{
|
|
261
|
-
await recv(hostInfo, [path.posix.join(remoteHome, remoteFiles[3])], path.resolve(localEmptyDir));
|
|
261
|
+
await recv(hostInfo, [path.posix.join(remoteHome, remoteFiles[3])], path.resolve(localEmptyDir), [], 0);
|
|
262
262
|
|
|
263
263
|
const rt2 = await fs.readdir(localEmptyDir);
|
|
264
264
|
expect(rt2).to.have.members(["piyo"]);
|
|
265
265
|
});
|
|
266
266
|
it("should accept relative src file and relative dst file name", async ()=>{
|
|
267
|
-
await recv(hostInfo, [remoteFiles[0]], path.join(localEmptyDir, "hoge"));
|
|
267
|
+
await recv(hostInfo, [remoteFiles[0]], path.join(localEmptyDir, "hoge"), [], 0);
|
|
268
268
|
|
|
269
269
|
const rt2 = await fs.readdir(localEmptyDir);
|
|
270
270
|
expect(rt2).to.have.members(["hoge"]);
|
|
271
271
|
});
|
|
272
272
|
it("should accept absolute src file and relative dst file name", async ()=>{
|
|
273
|
-
await recv(hostInfo, [path.posix.join(remoteHome, remoteFiles[0])], path.join(localEmptyDir, "hoge"));
|
|
273
|
+
await recv(hostInfo, [path.posix.join(remoteHome, remoteFiles[0])], path.join(localEmptyDir, "hoge"), [], 0);
|
|
274
274
|
|
|
275
275
|
const rt2 = await fs.readdir(localEmptyDir);
|
|
276
276
|
expect(rt2).to.have.members(["hoge"]);
|
|
277
277
|
});
|
|
278
278
|
it("should accept relative src file and absolute dst file name", async ()=>{
|
|
279
|
-
await recv(hostInfo, [remoteFiles[0]], path.resolve(localEmptyDir, "hoge"));
|
|
279
|
+
await recv(hostInfo, [remoteFiles[0]], path.resolve(localEmptyDir, "hoge"), [], 0);
|
|
280
280
|
|
|
281
281
|
const rt2 = await fs.readdir(localEmptyDir);
|
|
282
282
|
expect(rt2).to.have.members(["hoge"]);
|
|
283
283
|
});
|
|
284
284
|
it("should accept absolute src file and absolute dst file name", async ()=>{
|
|
285
|
-
await recv(hostInfo, [path.posix.join(remoteHome, remoteFiles[0])], path.resolve(localEmptyDir, "hoge"));
|
|
285
|
+
await recv(hostInfo, [path.posix.join(remoteHome, remoteFiles[0])], path.resolve(localEmptyDir, "hoge"), [], 0);
|
|
286
286
|
|
|
287
287
|
const rt2 = await fs.readdir(localEmptyDir);
|
|
288
288
|
expect(rt2).to.have.members(["hoge"]);
|
|
289
289
|
});
|
|
290
290
|
it("should accept glob pattern as src", async ()=>{
|
|
291
|
-
await recv(hostInfo, [path.posix.join(remoteRoot, "b*")], path.resolve(localEmptyDir));
|
|
291
|
+
await recv(hostInfo, [path.posix.join(remoteRoot, "b*")], path.resolve(localEmptyDir), [], 0);
|
|
292
292
|
|
|
293
293
|
const rt2 = await fs.readdir(localEmptyDir);
|
|
294
294
|
expect(rt2).to.have.members(["bar", "baz"]);
|
|
295
295
|
});
|
|
296
296
|
it("should accept glob pattern as src", async ()=>{
|
|
297
|
-
await recv(hostInfo, [path.posix.join(remoteRoot, "*/p[iu]yo")], path.resolve(localEmptyDir));
|
|
297
|
+
await recv(hostInfo, [path.posix.join(remoteRoot, "*/p[iu]yo")], path.resolve(localEmptyDir), [], 0);
|
|
298
298
|
|
|
299
299
|
const rt2 = await fs.readdir(localEmptyDir);
|
|
300
300
|
expect(rt2).to.have.members(["piyo", "puyo"]);
|
|
301
301
|
});
|
|
302
302
|
it.skip("[temporarily disabled number 23 was thrown] should accept glob pattern as src", async ()=>{
|
|
303
|
-
await recv(hostInfo, [path.posix.join(remoteRoot, "hoge/p[iu]yo"), path.posix.join(remoteRoot, "foo")], path.resolve(localEmptyDir));
|
|
303
|
+
await recv(hostInfo, [path.posix.join(remoteRoot, "hoge/p[iu]yo"), path.posix.join(remoteRoot, "foo")], path.resolve(localEmptyDir), [], 0);
|
|
304
304
|
|
|
305
305
|
const rt2 = await fs.readdir(localEmptyDir);
|
|
306
306
|
expect(rt2).to.have.members(["piyo", "puyo", "foo"]);
|
|
@@ -308,7 +308,7 @@ describe("test rsync exec", function() {
|
|
|
308
308
|
});
|
|
309
309
|
describe("recieve directory tree", ()=>{
|
|
310
310
|
it("should get directory tree which match specified glob", async ()=>{
|
|
311
|
-
await recv(hostInfo, [path.posix.join(remoteRoot, "?o*")], localEmptyDir);
|
|
311
|
+
await recv(hostInfo, [path.posix.join(remoteRoot, "?o*")], localEmptyDir, [], 0);
|
|
312
312
|
|
|
313
313
|
let rt2 = await fs.readdir(localEmptyDir);
|
|
314
314
|
expect(rt2).to.have.members(["foo", "hoge"]);
|
|
@@ -316,7 +316,7 @@ describe("test rsync exec", function() {
|
|
|
316
316
|
expect(rt2).to.have.members(["piyo", "puyo", "poyo"]);
|
|
317
317
|
});
|
|
318
318
|
it("should accept relative src dirname and relative dst dirname", async ()=>{
|
|
319
|
-
await recv(hostInfo, [remoteRoot], localEmptyDir);
|
|
319
|
+
await recv(hostInfo, [remoteRoot], localEmptyDir, [], 0);
|
|
320
320
|
|
|
321
321
|
let rt2 = await fs.readdir(path.posix.join(localEmptyDir, remoteRoot));
|
|
322
322
|
expect(rt2).to.have.members(["foo", "bar", "baz", "hoge", "huga"]);
|
|
@@ -324,7 +324,7 @@ describe("test rsync exec", function() {
|
|
|
324
324
|
expect(rt2).to.have.members(["piyo", "puyo", "poyo"]);
|
|
325
325
|
});
|
|
326
326
|
it("should accept absolute src dirname and relative dst dirname", async ()=>{
|
|
327
|
-
await recv(hostInfo, [path.posix.join(remoteHome, remoteRoot)], localEmptyDir);
|
|
327
|
+
await recv(hostInfo, [path.posix.join(remoteHome, remoteRoot)], localEmptyDir, [], 0);
|
|
328
328
|
|
|
329
329
|
let rt2 = await fs.readdir(path.posix.join(localEmptyDir, remoteRoot));
|
|
330
330
|
expect(rt2).to.have.members(["foo", "bar", "baz", "hoge", "huga"]);
|
|
@@ -332,7 +332,7 @@ describe("test rsync exec", function() {
|
|
|
332
332
|
expect(rt2).to.have.members(["piyo", "puyo", "poyo"]);
|
|
333
333
|
});
|
|
334
334
|
it("should accept relative src dirname and absolute dst dirname", async ()=>{
|
|
335
|
-
await recv(hostInfo, [remoteRoot], path.resolve(localEmptyDir));
|
|
335
|
+
await recv(hostInfo, [remoteRoot], path.resolve(localEmptyDir), [], 0);
|
|
336
336
|
|
|
337
337
|
let rt2 = await fs.readdir(path.posix.join(localEmptyDir, remoteRoot));
|
|
338
338
|
expect(rt2).to.have.members(["foo", "bar", "baz", "hoge", "huga"]);
|
|
@@ -340,7 +340,7 @@ describe("test rsync exec", function() {
|
|
|
340
340
|
expect(rt2).to.have.members(["piyo", "puyo", "poyo"]);
|
|
341
341
|
});
|
|
342
342
|
it("should accept absolute src dirname and absolute dst dirname", async ()=>{
|
|
343
|
-
await recv(hostInfo, [path.posix.join(remoteHome, remoteRoot)], path.resolve(localEmptyDir));
|
|
343
|
+
await recv(hostInfo, [path.posix.join(remoteHome, remoteRoot)], path.resolve(localEmptyDir), [], 0);
|
|
344
344
|
|
|
345
345
|
let rt2 = await fs.readdir(path.posix.join(localEmptyDir, remoteRoot));
|
|
346
346
|
expect(rt2).to.have.members(["foo", "bar", "baz", "hoge", "huga"]);
|
|
@@ -348,7 +348,7 @@ describe("test rsync exec", function() {
|
|
|
348
348
|
expect(rt2).to.have.members(["piyo", "puyo", "poyo"]);
|
|
349
349
|
});
|
|
350
350
|
it.skip("[not implemented] should recv files which matches only filter", async ()=>{
|
|
351
|
-
await recv(hostInfo, [remoteRoot], localEmptyDir, "*/{ba*,hoge/*}");
|
|
351
|
+
await recv(hostInfo, [remoteRoot], localEmptyDir, "*/{ba*,hoge/*}", [], 0);
|
|
352
352
|
|
|
353
353
|
let rt2 = await fs.readdir(path.posix.join(localEmptyDir, remoteRoot));
|
|
354
354
|
expect(rt2).to.have.members(["bar", "baz", "hoge"]);
|
|
@@ -356,13 +356,13 @@ describe("test rsync exec", function() {
|
|
|
356
356
|
expect(rt2).to.have.members(["piyo", "puyo", "poyo"]);
|
|
357
357
|
});
|
|
358
358
|
it("should not recv files which matches exclude filter", async ()=>{
|
|
359
|
-
await recv(hostInfo, [remoteRoot], localEmptyDir, ["--exclude=*/ba*", "--exclude=hoge"]);
|
|
359
|
+
await recv(hostInfo, [remoteRoot], localEmptyDir, ["--exclude=*/ba*", "--exclude=hoge"], [], 0);
|
|
360
360
|
|
|
361
361
|
const rt2 = await fs.readdir(path.posix.join(localEmptyDir, remoteRoot));
|
|
362
362
|
expect(rt2).to.have.members(["foo", "huga"]);
|
|
363
363
|
});
|
|
364
364
|
it.skip("[not implemented] should recv files which matches only filter but should not recv which matches exclude filter", async ()=>{
|
|
365
|
-
await recv(hostInfo, [remoteRoot], localEmptyDir, "*/{ba*,hoge/*}", "**/piyo");
|
|
365
|
+
await recv(hostInfo, [remoteRoot], localEmptyDir, "*/{ba*,hoge/*}", "**/piyo", [], 0);
|
|
366
366
|
|
|
367
367
|
let rt2 = await fs.readdir(path.posix.join(localEmptyDir, remoteRoot));
|
|
368
368
|
expect(rt2).to.have.members(["bar", "baz", "hoge"]);
|
|
@@ -372,7 +372,7 @@ describe("test rsync exec", function() {
|
|
|
372
372
|
});
|
|
373
373
|
describe("error case", ()=>{
|
|
374
374
|
it("should not send directory to existing file path", ()=>{
|
|
375
|
-
return expect(recv(hostInfo, [remoteRoot], localFiles[0])).to.be.rejected;
|
|
375
|
+
return expect(recv(hostInfo, [remoteRoot], localFiles[0], [], 0)).to.be.rejected;
|
|
376
376
|
});
|
|
377
377
|
});
|
|
378
378
|
});
|
package/test/sshExec.js
CHANGED
|
@@ -36,14 +36,14 @@ describe("test for ssh execution", function() {
|
|
|
36
36
|
describe("#exec", ()=>{
|
|
37
37
|
const testText = "hoge";
|
|
38
38
|
it("should execute single command with stdout", async ()=>{
|
|
39
|
-
const rt = await sshExec(hostInfo, `echo ${testText}`, sshout);
|
|
39
|
+
const rt = await sshExec(hostInfo, `echo ${testText}`, 0, sshout);
|
|
40
40
|
expect(rt).to.equal(0);
|
|
41
41
|
expect(sshout).to.be.called;
|
|
42
42
|
|
|
43
43
|
expect(sshout).to.be.calledWithMatch(/^hoge/);
|
|
44
44
|
});
|
|
45
45
|
it("should execute single command with stderr", async ()=>{
|
|
46
|
-
const rt = await sshExec(hostInfo, `echo ${testText} >&2`, sshout);
|
|
46
|
+
const rt = await sshExec(hostInfo, `echo ${testText} >&2`, 0, sshout);
|
|
47
47
|
expect(rt).to.equal(0);
|
|
48
48
|
expect(sshout).to.be.called;
|
|
49
49
|
expect(sshout).to.be.calledWithMatch(/^hoge/);
|
|
@@ -61,6 +61,9 @@ describe("test for ssh execution", function() {
|
|
|
61
61
|
const rt = await sshExec(hostInfo, `./${nonExisting}`);
|
|
62
62
|
expect(rt).to.equal(127);
|
|
63
63
|
});
|
|
64
|
+
it("should be rejected if timeout expired", async ()=>{
|
|
65
|
+
return expect(sshExec(hostInfo, "sleep 60", 1)).to.be.rejectedWith("watchdog timer expired");
|
|
66
|
+
});
|
|
64
67
|
});
|
|
65
68
|
describe("#canConnect", ()=>{
|
|
66
69
|
let hostInfo2;
|
|
@@ -106,31 +109,31 @@ describe("test for ssh execution", function() {
|
|
|
106
109
|
await createRemoteFiles(hostInfo);
|
|
107
110
|
});
|
|
108
111
|
it("should return array of file and directory names in the specified directory", async ()=>{
|
|
109
|
-
expect(await ls(hostInfo, remoteRoot)).to.have.members(["foo", "bar", "baz", "hoge", "huga"]);
|
|
112
|
+
expect(await ls(hostInfo, remoteRoot, [], 0)).to.have.members(["foo", "bar", "baz", "hoge", "huga"]);
|
|
110
113
|
});
|
|
111
114
|
it("should return array which has only specified file", async ()=>{
|
|
112
|
-
expect(await ls(hostInfo, path.posix.join(remoteRoot, "foo"))).to.eql([path.posix.join(remoteRoot, "foo")]);
|
|
115
|
+
expect(await ls(hostInfo, path.posix.join(remoteRoot, "foo"), [], 0)).to.eql([path.posix.join(remoteRoot, "foo")]);
|
|
113
116
|
});
|
|
114
117
|
it("should return 'No such file or directory' if non-existing path is specified", async ()=>{
|
|
115
|
-
expect(await ls(hostInfo, path.posix.join(remoteRoot, nonExisting))).to.match(/No such file or directory/);
|
|
118
|
+
expect(await ls(hostInfo, path.posix.join(remoteRoot, nonExisting), [], 0)).to.match(/No such file or directory/);
|
|
116
119
|
});
|
|
117
120
|
it("should return only matched filenames, if glob is specified", async ()=>{
|
|
118
|
-
expect(await ls(hostInfo, path.posix.join(remoteRoot, "b*"))).to.have.members(["bar", "baz"].map((e)=>{
|
|
121
|
+
expect(await ls(hostInfo, path.posix.join(remoteRoot, "b*"), [], 0)).to.have.members(["bar", "baz"].map((e)=>{
|
|
119
122
|
return path.posix.join(remoteRoot, e);
|
|
120
123
|
}));
|
|
121
124
|
});
|
|
122
125
|
it("should return only matched filenames src contains multipl glob pattern", async ()=>{
|
|
123
|
-
expect(await ls(hostInfo, path.posix.join(remoteRoot, "h*", "p[iu]yo"))).to.have.members(["piyo", "puyo"].map((e)=>{
|
|
126
|
+
expect(await ls(hostInfo, path.posix.join(remoteRoot, "h*", "p[iu]yo"), [], 0)).to.have.members(["piyo", "puyo"].map((e)=>{
|
|
124
127
|
return path.posix.join(remoteRoot, "hoge", e);
|
|
125
128
|
}));
|
|
126
129
|
});
|
|
127
130
|
it("should return only matched filenames, if specified glob contains /", async ()=>{
|
|
128
|
-
expect(await ls(hostInfo, path.posix.join(remoteRoot, "hoge/*yo"))).to.have.members(["piyo", "puyo", "poyo"].map((e)=>{
|
|
131
|
+
expect(await ls(hostInfo, path.posix.join(remoteRoot, "hoge/*yo"), [], 0)).to.have.members(["piyo", "puyo", "poyo"].map((e)=>{
|
|
129
132
|
return path.posix.join(remoteRoot, "hoge", e);
|
|
130
133
|
}));
|
|
131
134
|
});
|
|
132
135
|
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;
|
|
136
|
+
expect(await ls(hostInfo, remoteEmptyDir, [], 0)).to.be.an("array").that.is.empty;
|
|
134
137
|
});
|
|
135
138
|
});
|
|
136
139
|
});
|