File tree Expand file tree Collapse file tree 1 file changed +16
-14
lines changed Expand file tree Collapse file tree 1 file changed +16
-14
lines changed Original file line number Diff line number Diff line change @@ -105,21 +105,23 @@ module.exports = class Upgrader {
105
105
log ( `Upgrading ${ packageName } from ${ installed } to ${ targetVersion } ` )
106
106
await this . pm . upgrade ( `${ packageName } @~${ targetVersion } ` )
107
107
108
- // the cached `pkg` field won't automatically update after running `this.pm.upgrade`
108
+ // The cached `pkg` field won't automatically update after running `this.pm.upgrade`.
109
+ // Also, `npm install pkg@~version` won't replace the original `"pkg": "^version"` field.
110
+ // So we have to manually update `this.pkg` and write to the file system in `runMigrator`
109
111
this . pkg [ depEntry ] [ packageName ] = `~${ targetVersion } `
110
- const pluginMigrator = loadModule ( ` ${ packageName } /migrator` , this . context )
111
-
112
- if ( pluginMigrator ) {
113
- await runMigrator (
114
- this . context ,
115
- {
116
- id : packageName ,
117
- apply : pluginMigrator ,
118
- baseVersion : installed
119
- } ,
120
- this . pkg
121
- )
122
- }
112
+ const noop = ( ) => { }
113
+ const pluginMigrator =
114
+ loadModule ( ` ${ packageName } /migrator` , this . context ) || noop
115
+
116
+ await runMigrator (
117
+ this . context ,
118
+ {
119
+ id : packageName ,
120
+ apply : pluginMigrator ,
121
+ baseVersion : installed
122
+ } ,
123
+ this . pkg
124
+ )
123
125
}
124
126
125
127
async getUpgradable ( includeNext ) {
You can’t perform that action at this time.
0 commit comments