Skip to content

Commit cc34d72

Browse files
authored
Fix Docker CP bug (#132)
1 parent 26dd2fd commit cc34d72

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

src/commander.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export class Commander {
4545
}
4646
}
4747

48-
await new Promise((r) => setTimeout(r, 5));
48+
await new Promise((r) => setTimeout(r, 10));
4949

5050
if (stage.isFinished()) {
5151
if (!stage.isSuccess()) {

src/job.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ export class Job {
393393
dockerCmd += "fi\n\"";
394394

395395
const {stdout: containerId} = await Utils.spawn(dockerCmd, this.cwd, {...process.env, ...this.expandedVariables});
396-
this.containerId = containerId.replace("\n", "");
396+
this.containerId = containerId.replace(/\r?\n/g, "");
397397

398398
time = process.hrtime();
399399
await Utils.spawn(`docker cp . ${this.containerId}:/builds/`, this.cwd);
@@ -467,8 +467,8 @@ export class Job {
467467
cp.stdout.on("data", (e) => outFunc(e, writeStreams.stdout.bind(writeStreams), (s) => chalk`{greenBright ${s}}`));
468468
cp.stderr.on("data", (e) => outFunc(e, writeStreams.stderr.bind(writeStreams), (s) => chalk`{redBright ${s}}`));
469469

470-
cp.on("exit", (code) => resolve(code ?? 0));
471-
cp.on("error", (err) => reject(err));
470+
cp.on("exit", (code) => setTimeout(() => resolve(code ?? 0), 10));
471+
cp.on("error", (err) => setTimeout(() => reject(err), 10));
472472
});
473473

474474
if (this.imageName) {

src/utils.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ export class Utils {
2323
});
2424
cp.on("exit", (status) => {
2525
if ((status ?? 0) === 0) {
26-
return resolve({stdout, stderr, output, status: status ?? 0});
26+
return setTimeout(() => resolve({stdout, stderr, output, status: status ?? 0}), 10);
2727
}
28-
return reject(new ExitError(`${output}`));
28+
return setTimeout(() => reject(new ExitError(`${output}`)), 10);
2929
});
3030
cp.on("error", (e) => {
31-
reject(new ExitError(`'${command}' had errors\n${e}`));
31+
return setTimeout(() => reject(new ExitError(`'${command}' had errors\n${e}`)), 10);
3232
});
3333

3434
});

0 commit comments

Comments
 (0)