Skip to content

Instantly share code, notes, and snippets.

@viniciusCamargo
Created February 12, 2017 06:37
Show Gist options
  • Save viniciusCamargo/96226f1138b830114b109c6c039c9c67 to your computer and use it in GitHub Desktop.
Save viniciusCamargo/96226f1138b830114b109c6c039c9c67 to your computer and use it in GitHub Desktop.
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