diff --git a/CHANGELOG.md b/CHANGELOG.md index 475e6c772..22a09a673 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ ## {{ UNRELEASED_VERSION }} - [{{ UNRELEASED_DATE }}]({{ UNRELEASED_LINK }}) +* Fixed crash when `config.yml` is empty instead of containing `{}` [#439](https://github.com/lando/core/issues/439) + ## v3.26.2 - [December 17, 2025](https://github.com/lando/core/releases/tag/v3.26.2) * Updated to use new Lando Alliance Apple Developer certificates diff --git a/lib/cli.js b/lib/cli.js index 91af82162..a37eccb38 100644 --- a/lib/cli.js +++ b/lib/cli.js @@ -558,7 +558,7 @@ module.exports = class Cli { const Yaml = require(`../lib/yaml`); const yaml = new Yaml(); const configFile = path.join(this.defaultConfig().userConfRoot, 'config.yml'); - const config = (fs.existsSync(configFile)) ? yaml.load(configFile) : {}; + const config = (fs.existsSync(configFile)) ? yaml.load(configFile) || {} : {}; const file = yaml.dump(configFile, _.assign({}, config, data)); return yaml.load(file); } diff --git a/lib/lando.js b/lib/lando.js index 496dadd61..3403e5c08 100644 --- a/lib/lando.js +++ b/lib/lando.js @@ -465,7 +465,7 @@ module.exports = class Lando { } // Load the config and augment so we can get an App - const config = lmerge({}, ..._.map(landoFiles, file => yaml.load(file))); + const config = lmerge({}, ..._.map(landoFiles, file => yaml.load(file) || {})); this.log.info('loading app %s from config files', config.name, landoFiles); // Return us some app! const App = require('./app'); diff --git a/utils/load-config-files.js b/utils/load-config-files.js index 53f0ef60d..923291de2 100644 --- a/utils/load-config-files.js +++ b/utils/load-config-files.js @@ -52,7 +52,7 @@ module.exports = files => _(files) .filter(source => fs.existsSync(source) || fs.existsSync(source.file)) // If the file is just a string lets map it to an object .map(source => { - return _.isString(source) ? {file: source, data: yaml.load(fs.readFileSync(source))} : source; + return _.isString(source) ? {file: source, data: yaml.load(fs.readFileSync(source)) || {}} : source; }) // Add on the root directory for mapping purposes .map(source => _.merge({}, source, {root: path.dirname(source.file)}))