Socket
Socket
Sign inDemoInstall

egg-mock

Package Overview
Dependencies
Maintainers
5
Versions
132
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

egg-mock - npm Package Compare versions

Comparing version 2.4.0 to 3.0.0

8

History.md
3.0.0 / 2017-02-13
==================
* deps: upgrade egg (#29)
* fix: bind messenger with app and agent (#28)
* feat: [BREAKING_CHANGE] can get error from .ready() (#27)
* test: remove unuse codes (#26)
2.4.0 / 2017-02-08

@@ -3,0 +11,0 @@ ==================

50

lib/app.js

@@ -21,6 +21,5 @@ 'use strict';

const INIT_ONCE_LISTENER = Symbol('initOnceListener');
const MESSENGER = Symbol('messenger');
const MOCK_APP_METHOD = [
'ready',
'_ready',
'_readyCallbacks',
'closed',

@@ -44,15 +43,12 @@ 'close',

ready.mixin(this);
// listen once, otherwise will throw exception when emit error without listenr
this.once('error', () => {});
co(this[INIT].bind(this))
.then(() => this.ready(true))
// TODO: implement ready(err)
// condition for error event
.catch(err => {
if (!this[APP_INIT]) {
this.emit('error', err);
} else {
// never run this line
/* istanbul ignore next */
console.error(err.stack);
}
this.ready(err);
});

@@ -72,3 +68,3 @@ }

const Application = egg.Application;
const Application = bindMessenger(egg.Application, agent);
const app = this._app = new Application(this.options);

@@ -80,2 +76,8 @@ debug('app instantiate');

yield app.ready();
const msg = {
action: 'egg-ready',
};
app.messenger._onMessage(msg);
agent.messenger._onMessage(msg);
debug('app ready');

@@ -212,1 +214,31 @@ }

}
function bindMessenger(Application, agent) {
const agentMessenger = agent.messenger;
return class MeesengerApplication extends Application {
constructor(options) {
super(options);
const appMessenger = this.messenger;
agentMessenger.send = new Proxy(agentMessenger.send, {
apply(target, thisArg, [ action, data ]) {
setImmediate(() => appMessenger._onMessage({ action, data }));
},
});
}
get messenger() {
return this[MESSENGER];
}
set messenger(m) {
m.send = new Proxy(m.send, {
apply(target, thisArg, [ action, data ]) {
setImmediate(() => agentMessenger._onMessage({ action, data }));
},
});
this[MESSENGER] = m;
}
get [Symbol.for('egg#eggPath')]() { return path.dirname(__dirname); }
};
}

@@ -19,2 +19,3 @@ 'use strict';

coverage: true,
clean: true,
};

@@ -21,0 +22,0 @@ options = Object.assign({}, defaults, options);

15

package.json
{
"name": "egg-mock",
"version": "2.4.0",
"version": "3.0.0",
"eggPlugin": {

@@ -27,10 +27,10 @@ "name": "egg-mock"

"coffee": "^3.3.0",
"debug": "^2.6.0",
"debug": "^2.6.1",
"detect-port": "^1.1.0",
"egg-utils": "^1.1.0",
"get-ready": "^1.0.0",
"get-ready": "^2.0.1",
"is-type-of": "^1.0.0",
"ko-sleep": "^1.0.2",
"merge-descriptors": "^1.0.1",
"mm": "^2.0.1",
"mm": "^2.1.0",
"rimraf": "^2.5.4"

@@ -40,11 +40,10 @@ },

"autod": "^2.7.1",
"egg": "^0.9.0",
"egg": "^0.12.0",
"egg-bin": "^2.0.2",
"egg-ci": "^1.1.0",
"eslint": "^3.14.0",
"eslint": "^3.15.0",
"eslint-config-egg": "^3.2.0",
"ko-sleep": "^1.0.2",
"pedding": "^1.1.0",
"sdk-base": "^3.0.1",
"supertest": "^2.0.1"
"supertest": "^3.0.0"
},

@@ -51,0 +50,0 @@ "ci": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc