Created
April 28, 2018 14:35
-
-
Save gte445e/ff092b600aa60ce7a867595a1ac60d4c to your computer and use it in GitHub Desktop.
Node script beautify and hint every js file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'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