fix(apps.helpers): make required boolean field pass with false value
This commit is contained in:
parent
a31ecca41a
commit
09a51fe90c
2 changed files with 4 additions and 4 deletions
|
@ -183,7 +183,7 @@ describe('Test: generateEnvFile()', () => {
|
|||
const app = await insertApp({}, appConfig, db);
|
||||
|
||||
// act & assert
|
||||
expect(() => generateEnvFile(Object.assign(app, { config: { TEST_FIELD: undefined } }))).toThrowError('Variable TEST_FIELD is required');
|
||||
expect(() => generateEnvFile(Object.assign(app, { config: { TEST_FIELD: undefined } }))).toThrowError('Variable test is required');
|
||||
});
|
||||
|
||||
it('Should throw an error if app does not exist', async () => {
|
||||
|
|
|
@ -197,8 +197,8 @@ export const generateEnvFile = (app: App) => {
|
|||
const formValue = castAppConfig(app.config)[field.env_variable];
|
||||
const envVar = field.env_variable;
|
||||
|
||||
if (formValue) {
|
||||
envFile += `${envVar}=${formValue}\n`;
|
||||
if (formValue || typeof formValue === 'boolean') {
|
||||
envFile += `${envVar}=${String(formValue)}\n`;
|
||||
} else if (field.type === 'random') {
|
||||
if (envMap.has(envVar)) {
|
||||
envFile += `${envVar}=${envMap.get(envVar)}\n`;
|
||||
|
@ -209,7 +209,7 @@ export const generateEnvFile = (app: App) => {
|
|||
envFile += `${envVar}=${randomString}\n`;
|
||||
}
|
||||
} else if (field.required) {
|
||||
throw new Error(`Variable ${field.env_variable} is required`);
|
||||
throw new Error(`Variable ${field.label || field.env_variable} is required`);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in a new issue