chdir-promise
Advanced tools
Comparing version 0.2.0 to 0.2.1
{ | ||
"name": "chdir-promise", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"description": "Change working dir and return a promise, a stack of folders is maintained to jump back", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -23,8 +23,8 @@ # chdir-promise | ||
```js | ||
chdir.to('foo/bar/folder') | ||
.then(function () { | ||
return 'foo'; // value to return | ||
}) | ||
.tap(chdir.back); | ||
// resolved with value 'foo' | ||
chdir.to('foo/bar/folder') | ||
.then(function () { | ||
return 'foo'; // value to return | ||
}) | ||
.tap(chdir.back); | ||
// resolved with value 'foo' | ||
``` | ||
@@ -34,2 +34,15 @@ | ||
**Advice** | ||
Put `chdir.back` into `.finally` callback to make sure it is always executed, even if there is an exception. | ||
```js | ||
chdir.to('foo/bar/folder') | ||
.then(function () { | ||
throw new Error('oh my'); | ||
}) | ||
.then(chdir.back) // not called! | ||
.finally(chdir.back); // called | ||
``` | ||
[q]: https://www.npmjs.com/package/q | ||
@@ -36,0 +49,0 @@ [spots]: https://www.npmjs.com/package/spots |
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
6014
99