Comparing version 1.0.1 to 1.0.2
@@ -98,3 +98,3 @@ var path = require('path') | ||
mkdirP.promise = function (p, opts) { | ||
return new Promise((resolve, reject) => { | ||
return new Promise(function (resolve, reject) { | ||
mkdirP(p, opts, function (err) { | ||
@@ -101,0 +101,0 @@ if (err) { |
{ | ||
"name": "mkdirp2", | ||
"description": "Recursively mkdir, like `mkdir -p`", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"author": "James Halliday <mail@substack.net> (http://substack.net)", | ||
@@ -16,6 +16,6 @@ "main": "index.js", | ||
"devDependencies": { | ||
"mock-fs": "^4.3.0", | ||
"tap": "^10.3.2" | ||
"mock-fs": "^3.12.1", | ||
"tap": "^5.8.0" | ||
}, | ||
"license": "MIT" | ||
} |
@@ -11,8 +11,11 @@ [![view on npm](http://img.shields.io/npm/v/mkdirp2.svg)](https://www.npmjs.org/package/mkdirp2) | ||
Extended with a promise method: | ||
## Differences | ||
```js | ||
mkdirp.promise('/tmp/tmp2/file') | ||
.then(() => console.log('Created')) | ||
.catch(err => console.error(`Failed: ${err.message}`)) | ||
``` | ||
1. Command-line executable and its dependencies removed, this fork is for Nodejs use only. | ||
2. Extended with a promise method: | ||
```js | ||
mkdirp.promise('tmp/tmp2/file') | ||
.then(() => console.log('Created')) | ||
.catch(err => console.error(`Failed: ${err.message}`)) | ||
``` |
@@ -9,24 +9,26 @@ var mkdirp = require('../') | ||
test('woo-promise', function (t) { | ||
t.plan(4) | ||
var x = Math.floor(Math.random() * Math.pow(16, 4)).toString(16) | ||
var y = Math.floor(Math.random() * Math.pow(16, 4)).toString(16) | ||
var z = Math.floor(Math.random() * Math.pow(16, 4)).toString(16) | ||
if (typeof Promise !== 'undefined') { | ||
test('woo-promise', function (t) { | ||
t.plan(4) | ||
var x = Math.floor(Math.random() * Math.pow(16, 4)).toString(16) | ||
var y = Math.floor(Math.random() * Math.pow(16, 4)).toString(16) | ||
var z = Math.floor(Math.random() * Math.pow(16, 4)).toString(16) | ||
var file = '/tmp/' + [x, y, z].join('/') | ||
var file = '/tmp/' + [x, y, z].join('/') | ||
mkdirp.promise(file, _0755) | ||
.catch(function (err) { | ||
t.fail(err) | ||
}) | ||
.then(function () { | ||
exists(file, function (ex) { | ||
t.ok(ex, 'file created') | ||
fs.stat(file, function (err, stat) { | ||
t.ifError(err) | ||
t.equal(stat.mode & _0777, _0755) | ||
t.ok(stat.isDirectory(), 'target not a directory') | ||
mkdirp.promise(file, _0755) | ||
.catch(function (err) { | ||
t.fail(err) | ||
}) | ||
.then(function () { | ||
exists(file, function (ex) { | ||
t.ok(ex, 'file created') | ||
fs.stat(file, function (err, stat) { | ||
t.ifError(err) | ||
t.equal(stat.mode & _0777, _0755) | ||
t.ok(stat.isDirectory(), 'target not a directory') | ||
}) | ||
}) | ||
}) | ||
}) | ||
}) | ||
}) | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
18381
530
21