@@ -191,10 +191,6 @@ class PublishCommand extends Command {
191
191
192
192
const tasks = [ ] ;
193
193
194
- if ( ! this . project . isIndependent ( ) && ! this . options . canary ) {
195
- tasks . push ( ( ) => this . updateVersionInLernaJson ( ) ) ;
196
- }
197
-
198
194
tasks . push ( ( ) => this . updateUpdatedPackages ( ) ) ;
199
195
200
196
if ( this . gitEnabled ) {
@@ -461,16 +457,6 @@ class PublishCommand extends Command {
461
457
return PromptUtilities . confirm ( "Are you sure you want to publish the above changes?" ) ;
462
458
}
463
459
464
- updateVersionInLernaJson ( ) {
465
- this . project . version = this . globalVersion ;
466
-
467
- return this . project . serializeConfig ( ) . then ( lernaConfigLocation => {
468
- if ( ! this . options . skipGit ) {
469
- return gitAdd ( [ lernaConfigLocation ] , this . execOpts ) ;
470
- }
471
- } ) ;
472
- }
473
-
474
460
runPackageLifecycle ( pkg , stage ) {
475
461
if ( pkg . scripts [ stage ] ) {
476
462
return runLifecycle ( pkg , stage , this . conf ) . catch ( err => {
@@ -489,6 +475,11 @@ class PublishCommand extends Command {
489
475
// my kingdom for async await :(
490
476
let chain = Promise . resolve ( ) ;
491
477
478
+ // preversion: Run BEFORE bumping the package version.
479
+ // version: Run AFTER bumping the package version, but BEFORE commit.
480
+ // postversion: Run AFTER bumping the package version, and AFTER commit.
481
+ // @see https://docs.npmjs.com/misc/scripts
482
+
492
483
// exec preversion lifecycle in root (before all updates)
493
484
chain = chain . then ( ( ) => this . runPackageLifecycle ( rootPkg , "preversion" ) ) ;
494
485
@@ -559,6 +550,17 @@ class PublishCommand extends Command {
559
550
) ;
560
551
}
561
552
553
+ if ( ! independentVersions && ! this . options . canary ) {
554
+ this . project . version = this . globalVersion ;
555
+
556
+ chain = chain . then ( ( ) =>
557
+ this . project . serializeConfig ( ) . then ( lernaConfigLocation => {
558
+ // commit the version update
559
+ changedFiles . add ( lernaConfigLocation ) ;
560
+ } )
561
+ ) ;
562
+ }
563
+
562
564
// exec version lifecycle in root (after all updates)
563
565
chain = chain . then ( ( ) => this . runPackageLifecycle ( rootPkg , "version" ) ) ;
564
566
0 commit comments