Skip to content

Commit c531a51

Browse files
committed
Reintroduced std out and std err output to terminal. Looking in folders makes you crazy. Kept the file output though
1 parent 9e6c18a commit c531a51

File tree

2 files changed

+32
-6
lines changed

2 files changed

+32
-6
lines changed

src/job.ts

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,13 @@ export class Job {
174174
return new Promise<any>((resolve, reject) => {
175175
const jobNameStr = this.getJobNameString();
176176
const outputFilesPath = this.getOutputFilesPath();
177+
178+
const split = script.split(" && ");
179+
split.forEach((s) => {
180+
console.log(`${jobNameStr} ${c.green(`\$ ${s}`)}`);
181+
fs.appendFileSync(outputFilesPath, `\$ ${s}\n`);
182+
});
183+
177184
const child = shelljs.exec(`${script}`, {
178185
cwd: this.cwd,
179186
env: this.getEnvs(),
@@ -188,12 +195,26 @@ export class Job {
188195

189196
if (child.stdout) {
190197
child.stdout.on("data", (buf) => {
198+
const lines = `${buf}`.split(/\r?\n/);
199+
lines.forEach((l) => {
200+
if (!l) {
201+
return;
202+
}
203+
process.stdout.write(`${jobNameStr} ${c.greenBright(">")} ${l}\n`);
204+
});
191205
fs.appendFileSync(outputFilesPath, `${buf}`);
192206
});
193207
}
194208
if (child.stderr) {
195209
child.stderr.on("data", (buf) => {
196-
fs.appendFileSync(outputFilesPath, `${c.red(`${buf}`)}`);
210+
const lines = `${buf}`.split(/\r?\n/);
211+
lines.forEach((l) => {
212+
if (!l) {
213+
return;
214+
}
215+
process.stderr.write(`${jobNameStr} ${c.redBright(">")} ${l}\n`);
216+
});
217+
fs.appendFileSync(outputFilesPath, `${buf}`);
197218
});
198219
}
199220

src/parser.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,21 @@ export class Parser {
3333
const orderedYml = [];
3434

3535
// Add .gitlab-ci.yml
36-
orderedYml.push(Parser.loadYaml(`${cwd}/.gitlab-ci.yml`));
37-
if (!orderedYml.last()) { // Fail if empty
38-
console.error(`${cwd}/.gitlab-ci.yml is empty`);
36+
let path = `${cwd}/.gitlab-ci.yml`;
37+
if (!fs.existsSync(path)) { // Fail if empty
38+
console.error(`${cwd}/.gitlab-ci.yml is not found`);
3939
process.exit(1);
4040
}
41+
orderedYml.push(Parser.loadYaml(`${cwd}/.gitlab-ci.yml`));
4142
orderedVariables.push(orderedYml.last().variables);
4243

43-
// Add .gitlab-ci.yml
44-
orderedYml.push(Parser.loadYaml(`${cwd}/.gitlab-ci-local.yml`));
44+
// Add .gitlab-ci-local.yml
45+
path = `${cwd}/.gitlab-ci-local.yml`;
46+
orderedYml.push(Parser.loadYaml(path));
4547
orderedVariables.push(orderedYml.last().variables || {});
48+
if (!orderedYml.last() || Object.keys(orderedYml.last()).length === 0) { // Warn if empty
49+
console.error(`WARN: ${cwd}/.gitlab-ci-local.yml is empty or not found`);
50+
}
4651

4752
// Add included yaml's.
4853
orderedYml.unshift({});

0 commit comments

Comments
 (0)