Skip to content

Instantly share code, notes, and snippets.

@tomsmeding
Last active August 29, 2015 14:23
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 tomsmeding/b87976538093a882c79d to your computer and use it in GitHub Desktop.
Save tomsmeding/b87976538093a882c79d to your computer and use it in GitHub Desktop.
#!/usr/bin/env node
"use strict";
var fs=require("fs");
var body;
if(process.argv[2]=="-"){
body="";
var res;
while(true){
res=fs.readSync(0,1024);
if(res[1]==0)break;
body+=res[0];
}
} else {
body=String(fs.readFileSync(process.argv[2]));
}
console.log(JSON.stringify(body));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment