Commit 158ad0c6 authored by Aral Balkan's avatar Aral Balkan

Initial add.

parents
################################################################################
#
# fs-extra-as-promised
#
# Very simple module that promisifies fs-extra using thrush to workaround the
# “Cannot promisify an API that has normal methods with 'Async'-suffix” issue
# when you try to promisify the same module from multiple other modules.
#
# Copyright © 2015 Aral Balkan. Released with ❤ by Ind.ie under an MIT license.
#
################################################################################
Promise = require 'bluebird'
fs = Promise.promisifyAll require 'fs-extra'
# Cannot automatically promisify exists()
fs.existsAsync = (filePath) ->
return new Promise ((fulfill, reject) ->
exists = fs.existsSync(filePath)
process.nextTick(->
fulfill(exists)
)
)
module.exports = fs
{
"name": "fs-extra-as-promised",
"version": "1.0.0",
"description": "Promisifies fs-extra with thrush. Works around the issue here: https://github.com/petkaantonov/bluebird/issues/740",
"main": "index.coffee",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "https://source.ind.ie/aral/fs-extra-as-promised.git"
},
"dependencies": {
"thrush": "0.0.7",
"fs-extra": "0.23.1"
},
"keywords": [
"fs-extra",
"thrush",
"promises"
],
"author": "Aral Balkan",
"license": "MIT"
}
# fs-extra as promised
Very simple module that promisifies fs-extra using thrush to workaround the [Cannot promisify an API that has normal methods with 'Async'-suffix issue](https://github.com/petkaantonov/bluebird/issues/740) when you try to promisify the same module from multiple other modules.
## Usage
fs = require 'fs-extra-as-promised'
fs.existsAsync '/Users'
.then (exists) ->
if exists
console.log 'Nice operating system you got there! ;)'
else
console.log 'Oh well… can’t win ’em all.'
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment