1- 'use strict' ;
1+ import fs from 'fs' ;
2+ import path from 'path' ;
3+ import semver from 'semver' ;
4+ import chalk from 'chalk' ;
5+ import conventionalRecommendedBump from 'conventional-recommended-bump' ;
6+ import figures from 'figures' ;
7+ import DotGitignore from 'dotgitignore' ;
8+ import checkpoint from '../checkpoint.mjs' ;
9+ import presetLoader from '../preset-loader.mjs' ;
10+ import runLifecycleScript from '../run-lifecycle-script.mjs' ;
11+ import writeFile from '../write-file.mjs' ;
12+ import { resolveUpdaterObjectFromArgument } from '../updaters/index.mjs' ;
213
3- const chalk = require ( 'chalk' ) ;
4- const checkpoint = require ( '../checkpoint' ) ;
5- const conventionalRecommendedBump = require ( 'conventional-recommended-bump' ) ;
6- const figures = require ( 'figures' ) ;
7- const fs = require ( 'fs' ) ;
8- const DotGitignore = require ( 'dotgitignore' ) ;
9- const path = require ( 'path' ) ;
10- const presetLoader = require ( '../preset-loader' ) ;
11- const runLifecycleScript = require ( '../run-lifecycle-script' ) ;
12- const semver = require ( 'semver' ) ;
13- const writeFile = require ( '../write-file' ) ;
14- const { resolveUpdaterObjectFromArgument } = require ( '../updaters' ) ;
1514let configsToUpdate = { } ;
1615const sanitizeQuotesRegex = / [ ' " ] + / g;
1716
@@ -83,7 +82,7 @@ async function Bump(args, version) {
8382
8483 newVersion = semver . inc ( version , releaseType , args . prerelease ) ;
8584 }
86- updateConfigs ( args , newVersion ) ;
85+ await updateConfigs ( args , newVersion ) ;
8786 } else {
8887 checkpoint (
8988 args ,
@@ -116,7 +115,7 @@ function getReleaseType(prerelease, expectedReleaseType, currentVersion) {
116115 if (
117116 shouldContinuePrerelease ( currentVersion , expectedReleaseType ) ||
118117 getTypePriority ( getCurrentActiveType ( currentVersion ) ) >
119- getTypePriority ( expectedReleaseType )
118+ getTypePriority ( expectedReleaseType )
120119 ) {
121120 return 'prerelease' ;
122121 }
@@ -196,11 +195,11 @@ function bumpVersion(releaseAs, currentVersion, args) {
196195 lernaPackage : args . lernaPackage ,
197196 ...( args . verbose
198197 ? {
199- debug : console . info . bind (
200- console ,
201- 'conventional-recommended-bump' ,
202- ) ,
203- }
198+ debug : console . info . bind (
199+ console ,
200+ 'conventional-recommended-bump' ,
201+ ) ,
202+ }
204203 : { } ) ,
205204 } ,
206205 args . parserOpts ,
@@ -219,28 +218,28 @@ function bumpVersion(releaseAs, currentVersion, args) {
219218 * @param newVersion version number to update to.
220219 * @return void
221220 */
222- function updateConfigs ( args , newVersion ) {
221+ async function updateConfigs ( args , newVersion ) {
223222 const dotgit = DotGitignore ( ) ;
224- args . bumpFiles . forEach ( function ( bumpFile ) {
225- const updater = resolveUpdaterObjectFromArgument ( bumpFile ) ;
223+ for ( const bumpFile of args . bumpFiles ) {
224+ const updater = await resolveUpdaterObjectFromArgument ( bumpFile ) ;
226225 if ( ! updater ) {
227- return ;
226+ continue ;
228227 }
229228 const configPath = path . resolve ( process . cwd ( ) , updater . filename ) ;
230229 try {
231230 if ( dotgit . ignore ( updater . filename ) ) {
232231 console . debug (
233232 `Not updating file '${ updater . filename } ', as it is ignored in Git` ,
234233 ) ;
235- return ;
234+ continue ;
236235 }
237236 const stat = fs . lstatSync ( configPath ) ;
238237
239238 if ( ! stat . isFile ( ) ) {
240239 console . debug (
241240 `Not updating '${ updater . filename } ', as it is not a file` ,
242241 ) ;
243- return ;
242+ continue ;
244243 }
245244 const contents = fs . readFileSync ( configPath , 'utf8' ) ;
246245 const newContents = updater . updater . writeVersion ( contents , newVersion ) ;
@@ -257,7 +256,7 @@ function updateConfigs(args, newVersion) {
257256 } catch ( err ) {
258257 if ( err . code !== 'ENOENT' ) console . warn ( err . message ) ;
259258 }
260- } ) ;
259+ }
261260}
262261
263- module . exports = Bump ;
262+ export default Bump ;
0 commit comments