mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-03-03 19:11:22 +01:00
fix: closes #13734, set process.env.NODE_ENV early using argv
if commander or one of the core deps isn't found then packageInstall.installAll is called and uses process.env.NODE_ENV, which was always undefined.
This commit is contained in:
@@ -5,6 +5,15 @@ const path = require('path');
|
|||||||
|
|
||||||
require('../../require-main');
|
require('../../require-main');
|
||||||
|
|
||||||
|
// https://github.com/NodeBB/NodeBB/issues/13734
|
||||||
|
// check dev flag early so packageInstall.installAll() can use it
|
||||||
|
const isDev = process.argv.some(arg =>
|
||||||
|
arg === '-d' ||
|
||||||
|
arg === '--dev' ||
|
||||||
|
(arg.startsWith('-') && !arg.startsWith('--') && arg.includes('d')));
|
||||||
|
|
||||||
|
process.env.NODE_ENV = isDev ? 'development' : (process.env.NODE_ENV || 'production');
|
||||||
|
|
||||||
const packageInstall = require('./package-install');
|
const packageInstall = require('./package-install');
|
||||||
const { paths } = require('../constants');
|
const { paths } = require('../constants');
|
||||||
|
|
||||||
@@ -96,7 +105,7 @@ nconf.argv(opts).env({
|
|||||||
separator: '__',
|
separator: '__',
|
||||||
});
|
});
|
||||||
|
|
||||||
process.env.NODE_ENV = process.env.NODE_ENV || 'production';
|
|
||||||
|
|
||||||
prestart.setupWinston();
|
prestart.setupWinston();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user