|
1 | 1 | package migrate |
2 | 2 |
|
3 | 3 | import ( |
4 | | - "github.com/pkg/errors" |
5 | 4 | "io/ioutil" |
6 | 5 | "os" |
7 | 6 | "path/filepath" |
8 | 7 | "strings" |
9 | 8 |
|
| 9 | + "github.com/pkg/errors" |
| 10 | + |
| 11 | + "github.com/vim-volt/volt/config" |
10 | 12 | "github.com/vim-volt/volt/gateway/builder" |
11 | 13 | "github.com/vim-volt/volt/lockjson" |
12 | 14 | "github.com/vim-volt/volt/logger" |
@@ -39,13 +41,7 @@ Description |
39 | 41 | All plugconf files are replaced with new contents.` |
40 | 42 | } |
41 | 43 |
|
42 | | -func (*plugconfConfigMigrater) Migrate() error { |
43 | | - // Read lock.json |
44 | | - lockJSON, err := lockjson.ReadNoMigrationMsg() |
45 | | - if err != nil { |
46 | | - return errors.Wrap(err, "could not read lock.json") |
47 | | - } |
48 | | - |
| 44 | +func (*plugconfConfigMigrater) Migrate(cfg *config.Config, lockJSON *lockjson.LockJSON) error { |
49 | 45 | results, parseErr := plugconf.ParseMultiPlugconf(lockJSON.Repos) |
50 | 46 | if parseErr.HasErrs() { |
51 | 47 | logger.Error("Please fix the following errors before migration:") |
@@ -82,21 +78,21 @@ func (*plugconfConfigMigrater) Migrate() error { |
82 | 78 | // After checking errors, write the content to files |
83 | 79 | for _, info := range infoList { |
84 | 80 | os.MkdirAll(filepath.Dir(info.path), 0755) |
85 | | - err = ioutil.WriteFile(info.path, info.content, 0644) |
| 81 | + err := ioutil.WriteFile(info.path, info.content, 0644) |
86 | 82 | if err != nil { |
87 | 83 | return err |
88 | 84 | } |
89 | 85 | } |
90 | 86 |
|
91 | 87 | // Begin transaction |
92 | | - err = transaction.Create() |
| 88 | + err := transaction.Create() |
93 | 89 | if err != nil { |
94 | 90 | return err |
95 | 91 | } |
96 | 92 | defer transaction.Remove() |
97 | 93 |
|
98 | 94 | // Build ~/.vim/pack/volt dir |
99 | | - err = builder.Build(false) |
| 95 | + err = builder.Build(false, cfg, lockJSON) |
100 | 96 | if err != nil { |
101 | 97 | return errors.Wrap(err, "could not build "+pathutil.VimVoltDir()) |
102 | 98 | } |
|
0 commit comments