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 96f73a0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
8 changes: 2 additions & 6 deletions lib/master.js
Original file line number Diff line number Diff line change
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
6 changes: 6 additions & 0 deletions lib/utils/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,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 96f73a0

Please sign in to comment.