Skip to content

Commit 68d3e9c

Browse files
committed
adding colors to output
1 parent c0ad89c commit 68d3e9c

File tree

4 files changed

+19
-7
lines changed

4 files changed

+19
-7
lines changed
File renamed without changes.

scripts/formatter.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ const glob = require('glob');
1010
const path = require('path');
1111
const decamelize = require('decamelize');
1212
const shell = require('child_process').execSync;
13+
const chalk = require('chalk');
1314

1415
const getFiles = (src, callback) => {
1516
glob(src + '/**', callback);
@@ -30,6 +31,10 @@ getFiles('../', (err, res) => {
3031
// Can be replaced in the future
3132
shell(`mv ${file} ${decamelize(file)}`);
3233

34+
if (file !== decamelize(file)) {
35+
console.log(`The file ${chalk.red(file)} was successfuly changed to ${chalk.green(decamelize(file))}`);
36+
}
37+
3338
// Replace for convention .h for .hpp
3439
if (path.extname(file) === '.h') {
3540
shell(`mv ${file} ${file.replace(/\.[^\.]+$/, '.hpp')}`);

scripts/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
"license": "MIT",
1111
"private": true,
1212
"dependencies": {
13+
"chalk": "^2.4.2",
14+
"decamelize": "^2.0.0",
1315
"glob": "^7.1.3"
1416
}
15-
}
17+
}

scripts/validate.js

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
/**
2-
* The All Algorithms C++ Validate.js
2+
* validate.js
3+
*
4+
* The All ▲lgorithms validator CLI
35
*
46
* Author: Carlos Abraham Hernandez
57
* https://abranhe.com (abraham@abranhe.com)
@@ -9,6 +11,7 @@
911
const glob = require('glob');
1012
const path = require('path');
1113
const decamelize = require('decamelize');
14+
const chalk = require('chalk');
1215
const shell = require('child_process').execSync;
1316

1417
const getFiles = (src, callback) => {
@@ -25,10 +28,12 @@ getFiles('../', (err, res) => {
2528
return;
2629
}
2730

28-
if(file !== decamelize(file)){
29-
console.log('Don\'t follow the All ▲lgorithms structure. :/');
30-
process.exit();
31-
}
31+
if (file !== decamelize(file)) {
32+
console.log(`The file ${chalk.red(path.basename(file))} does not follow the correct style.`);
33+
// Stop when a file with wrong format is found
34+
throw new TypeError(`File project style does not follow the All ▲lgorithms structure.`);
35+
}
36+
console.log(`The file ${chalk.green(path.basename(file))} is ok.`);
3237
});
3338
}
34-
});
39+
});

0 commit comments

Comments
 (0)