Skip to content

Instantly share code, notes, and snippets.

@techwraith
Forked from bclinkinbeard/gist:8660778
Last active January 4, 2016 18:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save techwraith/8660828 to your computer and use it in GitHub Desktop.
Save techwraith/8660828 to your computer and use it in GitHub Desktop.
module.exports = function (path, opts) {
return function (err, src) {
if (!opts) opts = {}
if (!path) throw new Error('Path must be provided')
if (err) {
throw err
}
fs.writeFileSync(path, src, 'utf8');
if (opts.debug) console.log('writing to ' + path)
});
}
@techwraith
Copy link
Author

to use:

var writer = require('./write-file')
var path = require('path')

var write = writer(path.join(__dirname, 'bundle.js'), {debug: true})

write(null, src) // writes the file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment