Guest User

Untitled

a guest
Apr 24th, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. var Seq = require('seq');
  2. var fs = require('fs');
  3.  
  4. Seq()
  5. .seq(fs.stat('./dir', this))
  6. .catch(function (err) {
  7. fs.mkdir('./dir', 0700, function (err) {
  8. if (err) {
  9. console.log("Couldn't mkdir ./dir: " + err);
  10. process.exit(1);
  11. }
  12. });
  13. })
  14. .seq(fs.open('./dir/file', 'a+', this.into('fd')))
  15. .catch(function (err) {
  16. console.log("Couldn't open file for appending: " + err);
  17. process.exit(1);
  18. })
  19. .seq(fs.write(this.vars.fd, towrite, 0, towrite.length, null, this))
  20. .catch(function (err) {
  21. console.log("Failed appending to file: " + err);
  22. process.exit(1);
  23. })
  24. .seq(function () {
  25. console.log("Successfully appended to file!");
  26. })
  27. ;
Add Comment
Please, Sign In to add comment