-
Notifications
You must be signed in to change notification settings - Fork 772
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Promise support #403
Promise support #403
Conversation
Need to fix my hacky tests since they fail on Node 4 & 5. |
Added basic README docs; should eventually migrate |
README.md
Outdated
@@ -69,11 +69,20 @@ Example: | |||
```js | |||
const fs = require('fs-extra') | |||
|
|||
// Async with promises: | |||
fs.copy('/tmp/myfile', '/tmp/mynewfile') | |||
.then(() => console.log("success!")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably not that important, but for the purpose of consistency in using '
, wouldn't it be better console.log("success!")
replaced with console.log('success!')
since we use '
pretty much everywhere else? It actually has been there since the beginning (I guess). I just saw it now and thought that's be nice that we fix it here 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, we should fix that; thanks for the catch. I also removed an old semicolon in these docs. 😉
Someone ought to make a tool to run eslint on code blocks in markdown.
README.md
Outdated
|
||
// Sync: | ||
try { | ||
fs.copySync('/tmp/myfile', '/tmp/mynewfile') | ||
console.log("success!") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here: console.log("success!")
-> console.log('success!')
?
README.md
Outdated
// Handle error | ||
}) | ||
|
||
// Async with callbacks: | ||
fs.copy('/tmp/myfile', '/tmp/mynewfile', err => { | ||
if (err) return console.error(err) | ||
console.log("success!") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also here, console.log("success!")
-> console.log('success!')
?
Other than that minor thing, LGTM. Nice work @RyanZim 👏 |
@manidlou Fixed. Should also add: I'd appreciate review/improvements to https://github.com/RyanZim/universalify as well. |
Nice work @RyanZim!
Thanks! |
|
I believe that's a great idea! Actually, that is specifically mentioned in standardjs docs: As it is mentioned there, they introduce two modules for that: I tried
Then, we can add a new So, @jprichardson, @RyanZim what do you think? Edit Maybe that'd be better I opened a new issue for that, IDK! 😕 |
@manidlou Yeah, new issue or PR for that. |
@jprichardson micro-promisify sets the |
Updated |
LGTM 👍 |
@jprichardson Updated PR to use universalify v0.1.0, which sets Anything else before the merge? |
Hurray! I was using |
Hi This is pretty cool because now i dont need |
@rijnhard I'm of the opinion that fs-extra should be as light as possible. Adding any-promise increases weight. I'm firmly opposed to this ATM. |
@RyanZim theres another alternative I've seen, where theres some variable or method that accepts an A+ promise implementation, then they use that for all the promise creation. import Q from 'q';
import fs from 'fs-extra';
fs.setPromise(Q.Promise); and in the code you use the standard es6 style promise as you would normally. |
Issue filed: #425 |
This uses https://github.com/RyanZim/universalify, a library I wrote for this purpose.
This is a semver-major change.
Needs docs(Done!), and we should add more tests in the future.🎉 Promises are here! 🎉