Skip to content

Instantly share code, notes, and snippets.

@gte445e
Created April 28, 2018 14:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gte445e/ff092b600aa60ce7a867595a1ac60d4c to your computer and use it in GitHub Desktop.
Save gte445e/ff092b600aa60ce7a867595a1ac60d4c to your computer and use it in GitHub Desktop.
Node script beautify and hint every js file
'use strict';
const glob = require("glob");
const { exec } = require('child_process');
glob("Pages//**//*.js", function (er, files) {
files.forEach(function (cmd) {
const jsBeautifyCmd = 'js-beautify ' + cmd + ' -r';
console.log('Executing...' + jsBeautifyCmd);
exec(jsBeautifyCmd, (err, stdout, stderr) => {
if (err) {
console.error(`exec error: ${err}`);
return;
}
console.log(stdout);
});
const jsHintCmd = 'jshint ' + cmd;
console.log('Executing...' + jsHintCmd);
exec(jsHintCmd, (err, stdout, stderr) => {
if (err) {
console.error(`exec error: ${err}`);
return;
}
console.log(stdout);
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment