Skip to content

Commit ae5b238

Browse files
committed
fix: make sure to only set environment in rc file, when defined by the user
1 parent b2a7639 commit ae5b238

File tree

2 files changed

+25
-12
lines changed

2 files changed

+25
-12
lines changed

commands/Make/PreloadFile.ts

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -51,21 +51,29 @@ export default class MakePreloadFile extends BaseGenerator {
5151
return this.environment.split(',')
5252
}
5353

54-
return this.prompt.multiple('Select the environment(s) in which you want to load this file', [
54+
return this.prompt.multiple(
55+
'Select the environment(s) in which you want to load this file',
56+
[
57+
{
58+
name: 'console',
59+
message: 'During ace commands',
60+
},
61+
{
62+
name: 'web',
63+
message: 'During HTTP server',
64+
},
65+
],
5566
{
56-
name: 'console',
57-
message: 'During ace commands',
58-
},
59-
{
60-
name: 'web',
61-
message: 'During HTTP server',
62-
},
63-
])
67+
validate(choices) {
68+
return choices && choices.length ? true : 'Please the environment for the preload file'
69+
},
70+
}
71+
)
6472
}
6573

6674
/**
6775
* Validates environments to ensure they are allowed. Especially when
68-
* define as a flag.
76+
* defined as a flag.
6977
*/
7078
private validateEnvironments(
7179
environments: string[]
@@ -117,7 +125,12 @@ export default class MakePreloadFile extends BaseGenerator {
117125
const relativePath = file.toJSON().relativepath
118126
const rcFile = new files.AdonisRcFile(ADONIS_ACE_CWD()!)
119127

120-
rcFile.setPreload(`./${slash(relativePath).replace(extname(relativePath), '')}`, environments)
128+
if (environments && environments.length) {
129+
rcFile.setPreload(`./${slash(relativePath).replace(extname(relativePath), '')}`, environments)
130+
} else {
131+
rcFile.setPreload(`./${slash(relativePath).replace(extname(relativePath), '')}`)
132+
}
133+
121134
rcFile.commit()
122135
}
123136
}

npm-audit.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ <h5 class="card-title">
5555
<div class="card">
5656
<div class="card-body">
5757
<h5 class="card-title">
58-
August 7th 2020, 7:11:30 am
58+
August 7th 2020, 7:14:13 am
5959
</h5>
6060
<p class="card-text">Last updated</p>
6161
</div>

0 commit comments

Comments
 (0)