func()

in ibazel/output_runner/output_runner.go [103:136]


func (o *OutputRunner) readConfigs(configPath string) []Optcmd {
	workspacePath, err := o.w.FindWorkspace()
	if err != nil {
		log.Fatalf("Error finding workspace: %v", err)
		os.Exit(5)
	}

	jsonFile, err := os.Open(filepath.Join(workspacePath, configPath))
	if os.IsNotExist(err) {
		// Note this is not attached to the os.IsNotExist because we don't want the
		// other error handler to catch if we hav already notified.
		if !notifiedUser {
			log.Banner(
				"Did you know iBazel can invoke programs like Gazelle, buildozer, and",
				"other BUILD file generators for you automatically based on bazel output?",
				"Documentation at: https://github.com/bazelbuild/bazel-watcher#output-runner")
		}
		notifiedUser = true
		return nil
	} else if err != nil {
		log.Errorf("Error reading config: %s", err)
		return nil
	}
	defer jsonFile.Close()

	byteValue, _ := ioutil.ReadAll(jsonFile)
	var optcmd []Optcmd
	err = json.Unmarshal(byteValue, &optcmd)
	if err != nil {
		log.Errorf("Error in .bazel_fix_commands.json: %s", err)
	}

	return optcmd
}