Created
May 19, 2015 05:18
-
-
Save gabrielfurini/a53c45e6ac89cfecf7ed to your computer and use it in GitHub Desktop.
NODE.JS Redirectr: A simple script to write new folders/files with a content that you desire
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
/****** NodeJS Redirecter *******/ | |
/* A simple script to write new folders/files based on an array with a content that you desire */ | |
/* IMPORTANT: All folders/files with the same name in the directory will be overwritten */ | |
'use strict'; | |
var fs = require('fs'), | |
folders = ['folder1', 'folder2', 'folder3'], | |
fileName = 'index.htm'; | |
folders.forEach(function(folder){ | |
fs.mkdir(__dirname + '/' + folder, function(){ | |
var filePath = __dirname + '/' + folder + '/' + fileName, | |
content = 'window.location = "http://www.yournewurl.com/'+folder+'";'; | |
fs.writeFile(filePath, content, function(err){ | |
if(err) throw err; | |
console.log(filePath + ' saved'); | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment