Skip to content

Instantly share code, notes, and snippets.

@YurySolovyov
Last active December 23, 2015 16:09
Show Gist options
  • Select an option

  • Save YurySolovyov/6660041 to your computer and use it in GitHub Desktop.

Select an option

Save YurySolovyov/6660041 to your computer and use it in GitHub Desktop.
var fs = require('fs');
var Pipe = require('./core').Pipe;
var getStatAndWriteToJSONFile = Pipe.create(function(file,next){
fs.stat(file, next);
}).then(function(err, stats, next){
if(!err){
var string = JSON.stringify(stats);
fs.writeFile('stats.json', string, next);
}else{
console.log('Stats Error.', err);
}
}).then(function(err){
if(!err){
console.log('Write Success.');
}else{
console.log('Write Error.', err);
}
});
getStatAndWriteToJSONFile.run('gr.psd');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment