Skip to content

Commit

Permalink
breaking: remove bluebird as dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
tunnckoCore committed Aug 24, 2016
1 parent 86265d6 commit 039bc27
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
26 changes: 18 additions & 8 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,27 @@ var NativePromise = require('native-promise')
* ```
*
* @name nativeOrAnother
* @param {Function} `[Prome]` custom promise module
* @param {Function} `[Promize]` custom promise module
* @return {Function} native Promise or another
* @api public
*/
module.exports = function nativeOrAnother (Prome) {
module.exports = function nativeOrAnother (Promize) {
if (NativePromise) return NativePromise
if (typeof Prome === 'function') {
Prome.___customPromise = true
return Prome
if (typeof Promize === 'function') {
Promize.___customPromise = true
return Promize
}
Prome = require('bluebird')
Prome.___bluebirdPromise = true
return Prome
try {
Promize = require('bluebird')
} catch (err) {
console.error('The file "%s" requires `Promise`,', module.parent.filename)
console.error('but neither `bluebird` nor `Promise` implementation were found.')
console.error('Please install `bluebird` yourself or give Promise implementation.')
console.error('See the https://github.com/tunnckoCore/native-or-another')
process.exit(1)
throw err
}

Promize.___bluebirdPromise = true
return Promize
}
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"test": "standard && node test.js"
},
"dependencies": {
"bluebird": "^3.1.1",
"native-promise": "^1.0.0"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ var test = require('assertit')
var semver = require('semver')
var getPromise = require('./index')

test('should use native Promise if available, Bluebird otherwise', function (done) {
test('should use native Promise if available, Bluebird if installed', function (done) {
var Promize = getPromise()
var promise = new Promize(function (resolve, reject) {
resolve(123)
Expand Down

0 comments on commit 039bc27

Please sign in to comment.