Skip to content

Commit

Permalink
chore: move option.serialization of validation into utils/options.js
Browse files Browse the repository at this point in the history
  • Loading branch information
waitingsong committed Feb 13, 2020
1 parent 8aa9fc2 commit 23fc7b3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
8 changes: 2 additions & 6 deletions lib/master.js
Expand Up @@ -65,12 +65,6 @@ class Master extends EventEmitter {
const frameworkPath = this.options.framework;
const frameworkPkg = utility.readJSONSync(path.join(frameworkPath, 'package.json'));

/* istanbul ignore next */
if (this.options.serialization && !semver.gte(process.version, '12.16.0')) {
const err = new Error('[master] agent_worker options.serialization requires Node.js >= v12.16.0');
this.logger.error(err);
}

this.log(`[master] =================== ${frameworkPkg.name} start =====================`);
this.logger.info(`[master] node version ${process.version}`);
/* istanbul ignore next */
Expand Down Expand Up @@ -254,7 +248,9 @@ class Master extends EventEmitter {
const debugPort = process.env.EGG_AGENT_DEBUG_PORT || 5800;
if (this.options.isDebug) opt.execArgv = process.execArgv.concat([ `--${semver.gte(process.version, '8.0.0') ? 'inspect' : 'debug'}-port=${debugPort}` ]);

/* istanbul ignore next */
if (semver.gte(process.version, '12.16.0')) {
/* istanbul ignore next */
if (this.options.serialization) {
opt.serialization = this.options.serialization;
}
Expand Down
7 changes: 7 additions & 0 deletions lib/utils/options.js
Expand Up @@ -7,6 +7,7 @@ const assert = require('assert');
const utils = require('egg-utils');
const is = require('is-type-of');
const deprecate = require('depd')('egg');
const semver = require('semver');

module.exports = function(options) {
const defaults = {
Expand Down Expand Up @@ -64,6 +65,12 @@ module.exports = function(options) {
const isDebug = process.execArgv.some(argv => argv.includes('--debug') || argv.includes('--inspect'));
if (isDebug) options.isDebug = isDebug;

/* istanbul ignore next */
if (options.serialization && !semver.gte(process.version, '12.16.0')) {
const err = new Error('[master] agent_worker options.serialization requires Node.js >= v12.16.0');
this.logger.error(err);
}

return options;
};

Expand Down

0 comments on commit 23fc7b3

Please sign in to comment.