Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var Seq = require('seq');
- var fs = require('fs');
- Seq()
- .seq(fs.stat('./dir', this))
- .catch(function (err) {
- fs.mkdir('./dir', 0700, function (err) {
- if (err) {
- console.log("Couldn't mkdir ./dir: " + err);
- process.exit(1);
- }
- });
- })
- .seq(fs.open('./dir/file', 'a+', this.into('fd')))
- .catch(function (err) {
- console.log("Couldn't open file for appending: " + err);
- process.exit(1);
- })
- .seq(fs.write(this.vars.fd, towrite, 0, towrite.length, null, this))
- .catch(function (err) {
- console.log("Failed appending to file: " + err);
- process.exit(1);
- })
- .seq(function () {
- console.log("Successfully appended to file!");
- })
- ;
Add Comment
Please, Sign In to add comment