Skip to content

Instantly share code, notes, and snippets.

@sebv
Created July 10, 2015 00:04
Show Gist options
  • Save sebv/a4cb31595c46b6648f18 to your computer and use it in GitHub Desktop.
Save sebv/a4cb31595c46b6648f18 to your computer and use it in GitHub Desktop.
import _fs from 'fs';
import assert from 'assert';
var B = require('bluebird');
let fs = {
open: B.promisify(_fs.open),
mkdir: B.promisify(_fs.mkdir),
exists: B.promisify(
function (path, done) {
_fs.exists (path, function (result) {
done(null, result);
});
})
};
fs.exists('qwerty').then((res) => {
assert(!res);
}).then(function() {
return fs.exists(__dirname);
}).then(function(res) {
assert(res);
}).then(function() {
return fs.exists(__dirname + '/bid.js');
}).then(function(res) {
assert(res);
}).done();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment