Last active
August 25, 2017 13:01
-
-
Save J2D2Development/102ef8f696366c5b43fe2406f98f4cf3 to your computer and use it in GitHub Desktop.
Using Node's fs module to strip multi spaces from a file
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
'use strict'; | |
const fs = require('fs'); | |
const pathSplitter = require('./path-splitter'); | |
const filePath = process.argv[2]; | |
fs.readFile(filePath, (err, data) => { | |
const stripped = data.toString().replace(/\s+/g, ' '); | |
fs.writeFile(pathSplitter(filePath, 'stripped'), stripped); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment