Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
exKAZUu committed Sep 16, 2023
1 parent 49ccc78 commit dcb1785
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
12 changes: 9 additions & 3 deletions packages/shared-lib-node/src/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ export const yargsOptionsBuilderForEnv = {
},
'cascade-env': {
description:
'Environment to load cascading .env files (e.g., `.env`, `.env.<environment>`, `.env.local` and `.env.<environment>.local`). Preferred over `auto-cascade-env`',
'Environment to load cascading .env files (e.g., `.env`, `.env.<environment>`, `.env.local` and `.env.<environment>.local`). Preferred over `cascade-node-env` and `auto-cascade-env`.',
type: 'string',
},
'cascade-node-env': {
description:
'Same with --cascade-env=<NODE_ENV>. If NODE_ENV is falsy, "development" is applied. Preferred over `cascade-env` and `auto-cascade-env`.',
'Same with --cascade-env=<NODE_ENV>. If NODE_ENV is falsy, "development" is applied. Preferred over `auto-cascade-env`.',
type: 'boolean',
},
'auto-cascade-env': {
Expand All @@ -38,7 +38,13 @@ export const yargsOptionsBuilderForEnv = {
* */
export function loadEnvironmentVariables(argv: Options, cwd: string): Record<string, string> {
let envPaths = (argv.env ?? []).map((envPath) => envPath.toString());
const cascade = argv.cascadeNodeEnv ? process.env.NODE_ENV || 'development' : argv.cascadeEnv;
const cascade =
argv.cascadeEnv ??
(argv.cascadeNodeEnv
? process.env.NODE_ENV || 'development'
: argv.autoCascadeEnv
? process.env.WB_ENV || process.env.APP_ENV || process.env.NODE_ENV || 'development'
: undefined);
if (typeof cascade === 'string') {
if (envPaths.length === 0) envPaths.push('.env');
envPaths = envPaths.flatMap((envPath) =>
Expand Down
1 change: 0 additions & 1 deletion packages/wb/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ await yargs(hideBin(process.argv))
.scriptName('wb')
.options(sharedOptionsBuilder)
.middleware((argv) => {
console.log(argv);
const workingDir = argv['working-dir'];
if (workingDir) {
const dirPath = path.resolve(workingDir);
Expand Down

0 comments on commit dcb1785

Please sign in to comment.