Skip to content

Commit 2d0cb83

Browse files
authored
Fix "ReferenceError: data is not defined" error in getYAMLFileConfig (#472)
With the previous logic data would never be defined outside of the try...catch block since const variables are block scoped.
1 parent 71af1bb commit 2d0cb83

File tree

1 file changed

+4
-3
lines changed
  • x/examples/website-wrapper-app/wrapper_app_project/.scripts

1 file changed

+4
-3
lines changed

x/examples/website-wrapper-app/wrapper_app_project/.scripts/config.mjs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,15 @@ export const DEFAULT_CONFIG = {
2525
export async function getYAMLFileConfig(filepath) {
2626
try {
2727
const data = await fs.readFile(filepath, 'utf8')
28+
29+
if (data) {
30+
return YAML.parse(data)
31+
}
2832
} catch (e) {
2933
if ('ENOENT' == e.code) {
3034
return {}
3135
}
3236
}
33-
if (data) {
34-
return YAML.parse(data)
35-
}
3637
}
3738

3839
export function getCliConfig(args) {

0 commit comments

Comments
 (0)