Socket
Socket
Sign inDemoInstall

egg-core

Package Overview
Dependencies
14
Maintainers
4
Versions
137
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 3.0.0 to 3.0.1

5

History.md
3.0.1 / 2017-04-10
==================
* fix: ensure deprecate display the right call stack (#67)
3.0.0 / 2017-03-07

@@ -3,0 +8,0 @@ ==================

23

lib/egg.js

@@ -61,2 +61,4 @@ 'use strict';

this[CLOSESET] = new Set();
// cache deprecate object by file
this[DEPRECATE] = new Map();

@@ -158,7 +160,10 @@ /**

get deprecate() {
if (!this[DEPRECATE]) {
// require depd when get, `process.env.NO_DEPRECATION = '*'` should be use when run test everytime
this[DEPRECATE] = require('depd')('egg');
const caller = utils.getCalleeFromStack();
if (!this[DEPRECATE].has(caller)) {
const deprecate = require('depd')('egg');
// dynamic set _file to caller
deprecate._file = caller;
this[DEPRECATE].set(caller, deprecate);
}
return this[DEPRECATE];
return this[DEPRECATE].get(caller);
}

@@ -205,3 +210,3 @@

// get filename from stack
const name = getCalleeFromStack();
const name = utils.getCalleeFromStack(true);
const done = this.readyCallback(name);

@@ -342,9 +347,1 @@

module.exports = EggCore;
function getCalleeFromStack() {
const _ = new Error();
/* istanbul ignore next */
const line = _.stack.split('\n')[3] || '';
const parsed = line.match(/\((.*?)\)/);
return parsed && parsed[1];
}

@@ -12,3 +12,3 @@ 'use strict';

/**
* Load confog/plugin.js from {EggLoader#loadUnits}
* Load config/plugin.js from {EggLoader#loadUnits}
*

@@ -15,0 +15,0 @@ * plugin.js is written below

@@ -61,2 +61,34 @@ 'use strict';

},
getCalleeFromStack(withLine) {
const limit = Error.stackTraceLimit;
const prep = Error.prepareStackTrace;
Error.prepareStackTrace = prepareObjectStackTrace;
Error.stackTraceLimit = 3;
// capture the stack
const obj = {};
Error.captureStackTrace(obj);
const callSite = obj.stack[2];
Error.prepareStackTrace = prep;
Error.stackTraceLimit = limit;
/* istanbul ignore next */
if (!callSite) return '<anonymous>';
const fileName = callSite.getFileName();
if (!withLine || !fileName) return fileName || '<anonymous>';
return `${fileName}:${callSite.getLineNumber()}:${callSite.getColumnNumber()}`;
},
};
/**
* Capture call site stack from v8.
* https://github.com/v8/v8/wiki/Stack-Trace-API
*/
function prepareObjectStackTrace(obj, stack) {
return stack;
}
{
"name": "egg-core",
"version": "3.0.0",
"version": "3.0.1",
"description": "A core Pluggable framework based on koa",

@@ -5,0 +5,0 @@ "main": "index.js",

SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc