Created
February 12, 2017 06:37
-
-
Save viniciusCamargo/96226f1138b830114b109c6c039c9c67 to your computer and use it in GitHub Desktop.
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
const fs = require('fs') | |
const cwd = process.cwd() | |
const contentToDelete = ` <link rel="SHORTCUT ICON" href="https://37signals.com/images/37.ico" />` | |
const file = 'ch01_About_37signals - Copy.html' | |
const replaceContent = (file, from, to) => { | |
fs.readFile(file, 'utf8', (err, data) => { | |
if (err) | |
throw err | |
const newContent = data.split(from).join(to) | |
fs.writeFile(file, newContent, (err) => { | |
if (err) | |
throw err | |
console.log(data) | |
}) | |
}) | |
} | |
fs.readdir(cwd, 'utf8', (err, files) => { | |
if (err) | |
throw err | |
files | |
.filter(f => f.endsWith('.html')) | |
.map(f => replaceContent(f, contentToDelete, '')) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment