Skip to content

Do not bail out if old-style config file is found #152

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 19, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions commands/root/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,16 +116,6 @@ func preRun(cmd *cobra.Command, args []string) {

// initConfigs initializes the configuration from the specified file.
func initConfigs() {
// Return error if an old configuration file is found
if old := paths.New(".cli-config.yml"); old.Exist() {
logrus.Errorf("Old configuration file detected: %s.", old)
logrus.Info("The name of this file has been changed to `arduino-cli.yaml`, please rename the file fix it.")
formatter.PrintError(
fmt.Errorf("old configuration file detected: %s", old),
"The name of this file has been changed to `arduino-cli.yaml`, please rename the file fix it.")
os.Exit(commands.ErrGeneric)
}

// Start with default configuration
if conf, err := configs.NewConfiguration(); err != nil {
logrus.WithError(err).Error("Error creating default configuration")
Expand Down Expand Up @@ -160,6 +150,17 @@ func initConfigs() {
commands.Config.Navigate("/", pwd.String())
}

// Read configuration from old configuration file if found, but output a warning.
if old := paths.New(".cli-config.yml"); old.Exist() {
logrus.Errorf("Old configuration file detected: %s.", old)
logrus.Info("The name of this file has been changed to `arduino-cli.yaml`, please rename the file fix it.")
formatter.PrintError(
fmt.Errorf("WARNING: Old configuration file detected: %s", old),
"The name of this file has been changed to `arduino-cli.yaml`, in a future release we will not support"+
"the old name `.cli-config.yml` anymore. Please rename the file to `arduino-cli.yaml` to silence this warning.")
readConfigFrom(old)
}

// Read configuration from environment vars
commands.Config.LoadFromEnv()

Expand Down