-
-
Save bfcoder/ca88c00724c27895b77e to your computer and use it in GitHub Desktop.
Prepend all JavaScript files with "use strict"; that don't have it yet
This file contains 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
// To run: | |
// npm install globby | |
// node prepend-use-strict.js | |
var globby = require('globby'); | |
var fs = require('fs'); | |
globby('**/*.js', function(err, files) { | |
for (var i = 0, m = files.length; i < m; i++) { | |
var fileContent = fs.readFileSync(files[i]).toString(); | |
if (!fileContent.match("use strict")) { | |
fileContent = "\"use strict\";\n\n" + fileContent; | |
fs.writeFileSync(files[i], fileContent); | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment