Added bloom.json fallback to allow current Bloom users to continue using bloom.json for the project configuration.
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
#include "Application.hpp"
|
#include "Application.hpp"
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <QFile>
|
||||||
#include <QJsonDocument>
|
#include <QJsonDocument>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
@@ -237,13 +238,28 @@ namespace Bloom
|
|||||||
auto configFile = QFile(QString::fromStdString(Paths::projectConfigPath()));
|
auto configFile = QFile(QString::fromStdString(Paths::projectConfigPath()));
|
||||||
|
|
||||||
if (!configFile.exists()) {
|
if (!configFile.exists()) {
|
||||||
throw InvalidConfig("Bloom configuration file (bloom.yaml) not found. Working directory: "
|
// Try looking for the old bloom.json config file
|
||||||
+ Paths::projectDirPath());
|
configFile.setFileName(QString::fromStdString(Paths::projectDirPath()) + "/bloom.json");
|
||||||
|
|
||||||
|
if (configFile.exists()) {
|
||||||
|
Logger::warning(
|
||||||
|
"The recommended project configuration file format changed from JSON to YAML in Bloom v0.11.0."
|
||||||
|
" Bloom could not find a bloom.yaml configuration file, but did find bloom.json. Please convert"
|
||||||
|
" bloom.json to YAML format and rename to \"bloom.yaml\". There are numerous online JSON -> YAML"
|
||||||
|
" converters. For now, bloom.json will be used in the absence of bloom.yaml."
|
||||||
|
);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
throw InvalidConfig(
|
||||||
|
"Bloom configuration file (bloom.yaml) not found. Working directory: " + Paths::projectDirPath()
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!configFile.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
if (!configFile.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||||
throw InvalidConfig("Failed to open Bloom configuration file (bloom.yaml) Working directory: "
|
throw InvalidConfig(
|
||||||
+ Paths::projectDirPath());
|
"Failed to open Bloom configuration file. Working directory: " + Paths::projectDirPath()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto configNode = YAML::Load(configFile.readAll().toStdString());
|
const auto configNode = YAML::Load(configFile.readAll().toStdString());
|
||||||
|
|||||||
@@ -33,6 +33,9 @@ namespace Bloom
|
|||||||
/*
|
/*
|
||||||
* Initially, we used the JSON format for project configuration files, but this was changed in version 0.11.0.
|
* Initially, we used the JSON format for project configuration files, but this was changed in version 0.11.0.
|
||||||
* See https://github.com/navnavnav/Bloom/issues/50 for more.
|
* See https://github.com/navnavnav/Bloom/issues/50 for more.
|
||||||
|
*
|
||||||
|
* Because JSON is a subset of YAML, we can (and do) fallback to bloom.json in the absence of bloom.yaml.
|
||||||
|
* See Application::loadProjectConfiguration() for more.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user