fs-extra-promise
Advanced tools
Comparing version 0.3.1 to 0.4.0
@@ -58,1 +58,15 @@ # Changelog | ||
* License update | ||
## 0.4.0 | ||
* `.useFs()` method | ||
* Update `fs-extra` dependency to v0.30.0 | ||
* Update `bluebird` dependency to v3.4.0 | ||
* Update dev dependencies | ||
* Change `main` in package.json to `./lib/` (closes #7) | ||
* JSDoc comments | ||
* README update | ||
* Replace `Makefile` with npm scripts | ||
* Travis tests against node v4 + v6 | ||
* Update `.npmignore` | ||
* Update license |
@@ -6,11 +6,24 @@ // -------------------- | ||
// modules | ||
var fsExtra = require('fs-extra'), | ||
var fs = require('fs-extra'), | ||
Promise = require('bluebird'); | ||
// exports | ||
var makeFs = function(Promise) { | ||
/** | ||
* Factory to create promisified version of fs-extra. | ||
* Adds promisified methods for all async methods | ||
* e.g. `fs.readFile(path, cb)` becomes `fs.readFileAsync(path)` | ||
* All original methods of `fs` and `fs-extra` modules are left untouched. | ||
* NB does not mutate `fs-extra` module - returns a new instance with extra methods added. | ||
* | ||
* @param {Object} fs - `fs-extra` module | ||
* @param {Object} Promise - Bluebird implementation to use | ||
* @returns {Object} - `fsExtra` with promisified methods added | ||
*/ | ||
var factory = function(fs, Promise) { | ||
// clone fs-extra | ||
var fs = {}; | ||
for (var methodName in fsExtra) { | ||
fs[methodName] = fsExtra[methodName]; | ||
var fsOriginal = fs; | ||
fs = {}; | ||
for (var methodName in fsOriginal) { | ||
fs[methodName] = fsOriginal[methodName]; | ||
} | ||
@@ -55,5 +68,23 @@ | ||
// usePromise method to set Promise used internally (e.g. by using bluebird-extra module) | ||
fs.usePromise = makeFs; | ||
// use methods to set Promise used internally (e.g. could use bluebird-extra module) | ||
// and version of `fs-extra` being promisified | ||
/** | ||
* Returns new instance of `fs-extra-promise` using the Promise implementation provided. | ||
* @param {Object} Promise - Promise implementation to use | ||
* @returns {Object} - Promisified `fs-extra` | ||
*/ | ||
fs.usePromise = function(Promise) { | ||
return factory(fsOriginal, Promise); | ||
}; | ||
/** | ||
* Returns new instance of `fs-extra-promise` using the `fs` implementation provided. | ||
* @param {Object} fs - Version of `fs-extra` to use | ||
* @returns {Object} - Promisified `fs-extra` | ||
*/ | ||
fs.useFs = function(fs) { | ||
return factory(fs, Promise); | ||
}; | ||
// return fs | ||
@@ -64,2 +95,2 @@ return fs; | ||
// export fs promisified with bluebird | ||
module.exports = makeFs(Promise); | ||
module.exports = factory(fs, Promise); |
{ | ||
"name": "fs-extra-promise", | ||
"version": "0.3.1", | ||
"version": "0.4.0", | ||
"description": "Node file system library and fs-extra module promisified with bluebird", | ||
"main": "./lib/index", | ||
"main": "./lib/", | ||
"author": { | ||
@@ -17,12 +17,12 @@ "name": "Overlook Motel" | ||
"dependencies": { | ||
"fs-extra": "^0.26.2", | ||
"bluebird": "^2.10.1" | ||
"fs-extra": "^0.30.0", | ||
"bluebird": "^3.4.0" | ||
}, | ||
"devDependencies": { | ||
"mocha": "^2.3.3", | ||
"chai": "^3.3.0", | ||
"chai-as-promised": "^5.1.0", | ||
"jshint": "^2.8.0", | ||
"istanbul": "^0.3.21", | ||
"coveralls": "^2.11.4" | ||
"mocha": "^2.5.3", | ||
"chai": "^3.5.0", | ||
"chai-as-promised": "^5.3.0", | ||
"jshint": "^2.9.2", | ||
"istanbul": "^0.4.3", | ||
"coveralls": "^2.11.9" | ||
}, | ||
@@ -38,4 +38,8 @@ "keywords": [ | ||
"scripts": { | ||
"test": "make test", | ||
"cover": "make cover" | ||
"test": "if [ $COVERAGE ]; then npm run coveralls; else npm run jshint && npm run test-main; fi", | ||
"jshint": "./node_modules/.bin/jshint lib test", | ||
"test-main": "./node_modules/mocha/bin/mocha --check-leaks --colors -t 10000 --reporter spec 'test/**/*.test.js'", | ||
"cover": "npm run cover-main && rm -rf coverage", | ||
"coveralls": "npm run cover-main && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage", | ||
"cover-main": "COVERAGE=true ./node_modules/.bin/istanbul cover ./node_modules/.bin/_mocha --report lcovonly -- -R spec 'test/**/*.test.js'" | ||
}, | ||
@@ -42,0 +46,0 @@ "engines": { |
Sorry, the diff of this file is not supported yet
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
78
6758
4
1
0
+ Addedbluebird@3.7.2(transitive)
+ Addedfs-extra@0.30.0(transitive)
- Removedbluebird@2.11.0(transitive)
- Removedfs-extra@0.26.7(transitive)
Updatedbluebird@^3.4.0
Updatedfs-extra@^0.30.0