Browse Source

[refactor] Removing bluebird as a dependency

0.7.0-breaking-rewrite
Muthu Kumar 6 years ago
parent
commit
ee8c0c4fa1
  1. 12
      src/lib/unit/caller.js
  2. 2
      src/runner/index.js
  3. 10
      src/strategy/index.js
  4. 1
      src/util/requireDeep.js
  5. 2
      src/util/symbols.js

12
src/lib/unit/caller.js

@ -2,10 +2,11 @@ const { isPromise } = require('../../util');
const caller = (test, state) => {
let value, error;
let value, error, errored;
try {
value = test(state);
} catch (e) {
errored = true;
error = e;
}
@ -13,12 +14,13 @@ const caller = (test, state) => {
if (promise) {
return value
.then(res => ({ resolve: res, promise: true }))
.catch(rej => ({ rejection: rej, promise: true }));
.then(res => ({ status: 'ok', resolve: res, promise: true }))
.catch(rej => ({ status: 'notOk', rejection: rej, promise: true }));
} else {
return Promise.resolve({
...(!error && {value}),
...(error && {error}),
status: errored ? 'notOk' : 'ok',
...(!errored && { value }),
...(errored && { error }),
promise: false,
});
}

2
src/runner/index.js

@ -1,5 +1,3 @@
const Promise = require('bluebird');
const { flatten } = require('../util');
const logger = require('../lib/logger');

10
src/strategy/index.js

@ -1,5 +1,3 @@
const Promise = require('bluebird');
const requireDeep = require('../util/requireDeep');
const Runner = require('../runner');
@ -40,9 +38,11 @@ class Strategy {
* @param {string|Array<string>=} options.pattern
*/
fetchSpecs (options) {
this.__await__.push(Promise.map(requireDeep(options), each => {
this.__gunnerInstances = this.compiler(this)(each);
}));
this.__await__.push(
Promise.all(
requireDeep(options).map(
each => this.__gunnerInstances = this.compiler(this)(each)
)));
return this;
}

1
src/util/requireDeep.js

@ -1,4 +1,3 @@
const Promise = require('bluebird');
const fs = require(`fs`).promises;
const {
map,

2
src/util/symbols.js

@ -3,6 +3,8 @@ module.exports = {
Start : Symbol('Start'),
End : Symbol('End'),
expect: Symbol('expect'),
pass: 'pass',
fail: 'fail',

Loading…
Cancel
Save