Skip to content

Commit 25abd78

Browse files
feat:Add 'Skip' option to bypass adding environment variables
1 parent 7de4bd9 commit 25abd78

File tree

3 files changed

+16
-5
lines changed

3 files changed

+16
-5
lines changed

src/adapters/base-class.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -526,21 +526,27 @@ export default class BaseClass {
526526
// validate: this.inquireRequireValidation,
527527
}));
528528

529+
if (includes(variablePreparationType, 'Skip')) {
530+
this.envVariables = [];
531+
}
532+
if (includes(variablePreparationType, 'Skip') && variablePreparationType.length > 1) {
533+
this.log("The 'Skip' option cannot be combined with other environment variable options. Please choose either 'Skip' or one or more of the other available options.", 'error');
534+
this.exit(1);
535+
}
529536
if (includes(variablePreparationType, 'Import variables from a stack')) {
530537
await this.importEnvFromStack();
531538
}
532539
if (includes(variablePreparationType, 'Manually add custom variables to the list')) {
533540
await this.promptForEnvValues();
534541
}
535-
if (includes(variablePreparationType, 'Import variables from the local env file')) {
542+
if (includes(variablePreparationType, 'Import variables from the .env.local file')) {
536543
await this.importVariableFromLocalConfig();
537544
}
538545

539546
if (this.envVariables.length) {
540547
this.printAllVariables();
541548
} else {
542-
this.log('Please provide env file!', 'error');
543-
this.exit(1);
549+
this.log('Skipped adding environment variables.', 'info');
544550
}
545551
}
546552

@@ -559,6 +565,10 @@ export default class BaseClass {
559565
path: this.config.projectBasePath,
560566
}).parsed;
561567

568+
if (isEmpty(localEnv)) {
569+
this.log('No .env.local file found.', 'error');
570+
this.exit(1);
571+
}
562572
if (!isEmpty(localEnv)) {
563573
let envKeys: Record<string, any> = keys(localEnv);
564574
const existingEnvKeys = map(this.envVariables, 'key');

src/commands/launch/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export default class Launch extends BaseCommand<typeof Launch> {
6262
'variable-type': Flags.string({
6363
options: [...config.variablePreparationTypeOptions],
6464
description:
65-
'[optional] Provide a variable type. <options: Import variables from a stack|Manually add custom variables to the list|Import variables from the local env file>',
65+
'[optional] Provide a variable type. <options: Import variables from a stack|Manually add custom variables to the list|Import variables from the .env.local file|Skip>',
6666
}),
6767
'show-variables': Flags.boolean({
6868
hidden: true,

src/config/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ const config = {
3737
variablePreparationTypeOptions: [
3838
'Import variables from a stack',
3939
'Manually add custom variables to the list',
40-
'Import variables from the local env file',
40+
'Import variables from the .env.local file',
41+
'Skip',
4142
],
4243
variableType: '',
4344
supportedFrameworksForServerCommands: ['ANGULAR', 'OTHER', 'REMIX'],

0 commit comments

Comments
 (0)