Skip to content

Commit 70bec7a

Browse files
authored
Remove garbage characters in the terminal (#999)
1 parent a5c1f0b commit 70bec7a

File tree

3 files changed

+30
-23
lines changed

3 files changed

+30
-23
lines changed

config/helpers.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import * as fs from 'fs';
33
import * as os from 'os';
44
import chalk from 'chalk';
55
import * as jsyaml from 'js-yaml';
6-
import { console } from './status';
76
import { rimraf } from 'rimraf';
87
import { isObject, isNil, isString, isEmpty } from 'lodash';
98

config/status.ts

Lines changed: 30 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
import * as nodeStatus from 'node-status';
21
import chalk from 'chalk';
3-
import { isString, find, isNil, isArray } from 'lodash';
2+
import { isString, isNil, isArray } from 'lodash';
43

54
interface IStage {
65
steps: any[];
@@ -13,16 +12,29 @@ export class Status {
1312
steps: { [step: string]: boolean } = {};
1413

1514
get console() {
16-
return nodeStatus.console();
15+
// Return the global console object methods
16+
return {
17+
log: global.console.log.bind(global.console),
18+
error: global.console.error.bind(global.console),
19+
warn: global.console.warn.bind(global.console),
20+
info: global.console.info.bind(global.console)
21+
};
1722
}
1823

1924
constructor() {
20-
/* Initialize the status library */
21-
this.stages = nodeStatus.addItem('stages', {
22-
steps: []
23-
});
25+
/* Initialize the simple status system */
26+
this.stages = {
27+
steps: [],
28+
count: 0,
29+
doneStep: this.doneStep.bind(this)
30+
};
31+
}
2432

25-
nodeStatus.start();
33+
private doneStep(completed: boolean, message?: string): void {
34+
const symbol = completed ? chalk.green('✓') : chalk.red('✗');
35+
if (message) {
36+
global.console.log(`${symbol} ${message}`);
37+
}
2638
}
2739

2840
/**
@@ -37,22 +49,18 @@ export class Status {
3749
success = success && additionalDetails.findIndex(item => item instanceof Error) < 0;
3850

3951
const messageArray = getDetailsArray();
52+
const symbol = success ? chalk.green('✓') : chalk.red('✗');
4053

41-
if (messageArray.length === 0) {
42-
this.stages.doneStep(success);
43-
} else {
44-
// Add a newline before
45-
messageArray.splice(0, 0, '');
46-
this.stages.doneStep(success, messageArray.join('\n * ') + '\n');
47-
//FIXME `${chalk.bold.red('WARNING: one of the messages above was an error')}`)
48-
}
49-
50-
this.steps[stage] = false;
54+
// Log the completion with symbol
55+
global.console.log(`${symbol} ${stage}`);
5156

52-
if (!find(this.steps as any, (item) => item === true)) {
53-
nodeStatus.stop();
57+
if (messageArray.length > 0) {
58+
messageArray.forEach(msg => {
59+
global.console.log(` * ${msg}`);
60+
});
5461
}
5562

63+
this.steps[stage] = false;
5664

5765
// Helper:
5866
function getDetailsArray() {
@@ -82,12 +90,13 @@ export class Status {
8290
}
8391

8492
/**
85-
* Add a new stage and complete the previous stage.
93+
* Add a new stage and mark it as started.
8694
* @param stage Name of the stage.
8795
*/
8896
add(stage: string) {
8997
this.stages.steps.push(stage);
9098
this.steps[stage] = true;
99+
global.console.log(chalk.cyan(`○ ${stage}`));
91100
}
92101
}
93102

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
"fs-extra": "11.3.2",
3030
"js-yaml": "^4.1.0",
3131
"lodash": "^4.17.21",
32-
"node-status": "^1.0.0",
3332
"rimraf": "^6.0.1",
3433
"shelljs": "^0.10.0"
3534
},

0 commit comments

Comments
 (0)