Skip to content

Instantly share code, notes, and snippets.

@J2D2Development
Last active August 25, 2017 13:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save J2D2Development/102ef8f696366c5b43fe2406f98f4cf3 to your computer and use it in GitHub Desktop.
Save J2D2Development/102ef8f696366c5b43fe2406f98f4cf3 to your computer and use it in GitHub Desktop.
Using Node's fs module to strip multi spaces from a file
'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