Skip to content

Instantly share code, notes, and snippets.

@msuzen
Last active January 2, 2018 14:07
Show Gist options
  • Select an option

  • Save msuzen/5e3852fd02adaff1048f6de3987a2e10 to your computer and use it in GitHub Desktop.

Select an option

Save msuzen/5e3852fd02adaff1048f6de3987a2e10 to your computer and use it in GitHub Desktop.
node.js read a text file to a string
/*
By msuzen GPLv3
See Also: https://stackoverflow.com/questions/3133243/how-do-i-get-the-path-to-the-current-script-with-node-js
*/
var fs = require('fs');
var shapes = fs.readFile(process.cwd() + '/' + options.shapes, function(err, data)
{
if(err)
console.log(err)
else
console.log(data.toString());
});
console.log(shapes)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment