Skip to content

Commit

Permalink
adding colors to output
Browse files Browse the repository at this point in the history
  • Loading branch information
abranhe committed Feb 21, 2019
1 parent c0ad89c commit 68d3e9c
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 7 deletions.
File renamed without changes.
5 changes: 5 additions & 0 deletions scripts/formatter.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const glob = require('glob');
const path = require('path');
const decamelize = require('decamelize');
const shell = require('child_process').execSync;
const chalk = require('chalk');

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

if (file !== decamelize(file)) {
console.log(`The file ${chalk.red(file)} was successfuly changed to ${chalk.green(decamelize(file))}`);
}

// Replace for convention .h for .hpp
if (path.extname(file) === '.h') {
shell(`mv ${file} ${file.replace(/\.[^\.]+$/, '.hpp')}`);
Expand Down
4 changes: 3 additions & 1 deletion scripts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
"license": "MIT",
"private": true,
"dependencies": {
"chalk": "^2.4.2",
"decamelize": "^2.0.0",
"glob": "^7.1.3"
}
}
}
17 changes: 11 additions & 6 deletions scripts/validate.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
/**
* The All Algorithms C++ Validate.js
* validate.js
*
* The All ▲lgorithms validator CLI
*
* Author: Carlos Abraham Hernandez
* https://abranhe.com ([email protected])
Expand All @@ -9,6 +11,7 @@
const glob = require('glob');
const path = require('path');
const decamelize = require('decamelize');
const chalk = require('chalk');
const shell = require('child_process').execSync;

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

if(file !== decamelize(file)){
console.log('Don\'t follow the All ▲lgorithms structure. :/');
process.exit();
}
if (file !== decamelize(file)) {
console.log(`The file ${chalk.red(path.basename(file))} does not follow the correct style.`);
// Stop when a file with wrong format is found
throw new TypeError(`File project style does not follow the All ▲lgorithms structure.`);
}
console.log(`The file ${chalk.green(path.basename(file))} is ok.`);
});
}
});
});

0 comments on commit 68d3e9c

Please sign in to comment.