summaryrefslogtreecommitdiffstats
path: root/build/change-version.mjs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--build/change-version.mjs (renamed from build/change-version.js)44
1 files changed, 28 insertions, 16 deletions
diff --git a/build/change-version.js b/build/change-version.mjs
index 9685df5..3c1e706 100644
--- a/build/change-version.js
+++ b/build/change-version.mjs
@@ -6,23 +6,22 @@
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
*/
-'use strict'
-
-const fs = require('node:fs').promises
-const path = require('node:path')
-const globby = require('globby')
+import { execFile } from 'node:child_process'
+import fs from 'node:fs/promises'
+import process from 'node:process'
const VERBOSE = process.argv.includes('--verbose')
const DRY_RUN = process.argv.includes('--dry') || process.argv.includes('--dry-run')
-// These are the filetypes we only care about replacing the version
-const GLOB = [
- '**/*.{css,html,js,json,md,scss,txt,yml}'
+// These are the files we only care about replacing the version
+const FILES = [
+ 'README.md',
+ 'hugo.yml',
+ 'js/src/base-component.js',
+ 'package.js',
+ 'scss/mixins/_banner.scss',
+ 'site/data/docs-versions.yml'
]
-const GLOBBY_OPTIONS = {
- cwd: path.join(__dirname, '..'),
- gitignore: true
-}
// Blame TC39... https://github.com/benjamingr/RegExp.escape/issues/37
function regExpQuote(string) {
@@ -53,7 +52,7 @@ async function replaceRecursively(file, oldVersion, newVersion) {
}
if (VERBOSE) {
- console.log(`FILE: ${file}`)
+ console.log(`Found ${oldVersion} in ${file}`)
}
if (DRY_RUN) {
@@ -63,6 +62,19 @@ async function replaceRecursively(file, oldVersion, newVersion) {
await fs.writeFile(file, newString, 'utf8')
}
+function bumpNpmVersion(newVersion) {
+ if (DRY_RUN) {
+ return
+ }
+
+ execFile('npm', ['version', newVersion, '--no-git-tag'], { shell: true }, error => {
+ if (error) {
+ console.error(error)
+ process.exit(1)
+ }
+ })
+}
+
function showUsage(args) {
console.error('USAGE: change-version old_version new_version [--verbose] [--dry[-run]]')
console.error('Got arguments:', args)
@@ -86,11 +98,11 @@ async function main(args) {
showUsage(args)
}
- try {
- const files = await globby(GLOB, GLOBBY_OPTIONS)
+ bumpNpmVersion(newVersion)
+ try {
await Promise.all(
- files.map(file => replaceRecursively(file, oldVersion, newVersion))
+ FILES.map(file => replaceRecursively(file, oldVersion, newVersion))
)
} catch (error) {
console.error(error)