Skip to content

Commit

Permalink
fix: NODE_OPTIONS should set to process.env/context.env (#237)
Browse files Browse the repository at this point in the history
  • Loading branch information
killagu authored Aug 25, 2023
1 parent 1bc19f9 commit 8e2f437
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/command.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class Command extends BaseCommand {

get context() {
const context = super.context;
const { argv, debugPort, execArgvObj, cwd, env } = context;
const { argv, debugPort, execArgvObj, cwd } = context;

// compatible
if (debugPort) context.debug = debugPort;
Expand Down Expand Up @@ -130,14 +130,15 @@ class Command extends BaseCommand {
} else {
process.env.NODE_OPTIONS = requireOptions;
}
context.env.NODE_OPTIONS = process.env.NODE_OPTIONS;
// tell egg loader to load ts file
// see https://github.com/eggjs/egg-core/blob/master/lib/loader/egg_loader.js#L443
env.EGG_TYPESCRIPT = 'true';
context.env.EGG_TYPESCRIPT = 'true';
// set current process.env.EGG_TYPESCRIPT too
process.env.EGG_TYPESCRIPT = 'true';

// load files from tsconfig on startup
env.TS_NODE_FILES = process.env.TS_NODE_FILES || 'true';
context.env.TS_NODE_FILES = process.env.TS_NODE_FILES || 'true';
}

// keep same logic with egg-core
Expand Down

0 comments on commit 8e2f437

Please sign in to comment.