| 82 | } |
| 83 | |
| 84 | func getPackagesAndCommitHash(c *cobra.Command) ([]string, string) { |
| 85 | configFlag := c.Flag("config") |
| 86 | // for shell, run, and add command, path can be set via --config |
| 87 | // if --config is not set, default to current directory which is "" |
| 88 | // the only exception is the init command, for the path can be set with args |
| 89 | // since after running init there will be no packages set in devbox.json |
| 90 | // we can safely ignore this case. |
| 91 | var path string |
| 92 | if configFlag != nil { |
| 93 | path = configFlag.Value.String() |
| 94 | } |
| 95 | |
| 96 | box, err := devbox.Open(&devopt.Opts{ |
| 97 | Dir: path, |
| 98 | Stderr: os.Stderr, |
| 99 | IgnoreWarnings: true, |
| 100 | }) |
| 101 | if err != nil { |
| 102 | return []string{}, "" |
| 103 | } |
| 104 | |
| 105 | return box.AllPackageNamesIncludingRemovedTriggerPackages(), |
| 106 | box.Lockfile().Stdenv().Rev |
| 107 | } |