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) => { const caller = (test, state) => {
let value, error; let value, error, errored;
try { try {
value = test(state); value = test(state);
} catch (e) { } catch (e) {
errored = true;
error = e; error = e;
} }
@ -13,12 +14,13 @@ const caller = (test, state) => {
if (promise) { if (promise) {
return value return value
.then(res => ({ resolve: res, promise: true })) .then(res => ({ status: 'ok', resolve: res, promise: true }))
.catch(rej => ({ rejection: rej, promise: true })); .catch(rej => ({ status: 'notOk', rejection: rej, promise: true }));
} else { } else {
return Promise.resolve({ return Promise.resolve({
...(!error && {value}), status: errored ? 'notOk' : 'ok',
...(error && {error}), ...(!errored && { value }),
...(errored && { error }),
promise: false, promise: false,
}); });
} }

2
src/runner/index.js

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

10
src/strategy/index.js

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

1
src/util/requireDeep.js

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

2
src/util/symbols.js

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

Loading…
Cancel
Save