Created
May 1, 2014 18:00
-
-
Save aaronfrost/043b23ccd1316775fd2f to your computer and use it in GitHub Desktop.
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
//In your Gruntfile | |
grunt.registerTask('replaceURL', '...', require('./urlReplacer.js')); | |
//Then in urlReplacer.js | |
var fs, r, oldfile, newfile; | |
fs = require('fs'); | |
r = new RegExp("some regex to match your url", 'g'); | |
//read the the file and replace the text | |
oldfile = fs.readFileSync(__dirname + '/file-with-url-that-needs-to-be-replaced.js', 'utf8'); | |
newfile = oldfile.replace(r, 'http://thenewurl.com'); | |
//write the file back to a temp dir with the right url | |
fs.writeFileSync(__dirname + '/file-with-url-that-needs-to-be-replaced.js', newfile); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment