aboutsummaryrefslogtreecommitdiff
path: root/build/change-version.js
diff options
context:
space:
mode:
authorBobby <[email protected]>2024-08-16 20:47:33 -0400
committerGitHub <[email protected]>2024-08-16 20:47:33 -0400
commit6b28433d9cfde435be8ec2bd6cf91e6324d08865 (patch)
tree8343c27b8b95ff5639233e81cf157f92e5688466 /build/change-version.js
parentd53094ec16ba385faae2973ddee648698b32ab24 (diff)
parent048f56f51460df75e92a2f7b472e1c56baeb68f7 (diff)
downloadbootstrap-main.tar.xz
bootstrap-main.zip
Merge branch 'twbs:main' into mainHEADmain
Diffstat (limited to 'build/change-version.js')
-rw-r--r--build/change-version.js81
1 files changed, 0 insertions, 81 deletions
diff --git a/build/change-version.js b/build/change-version.js
deleted file mode 100644
index 22a169db9..000000000
--- a/build/change-version.js
+++ /dev/null
@@ -1,81 +0,0 @@
-#!/usr/bin/env node
-
-/*!
- * Script to update version number references in the project.
- * Copyright 2017-2021 The Bootstrap Authors
- * Copyright 2017-2021 Twitter, Inc.
- * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
- */
-
-'use strict'
-
-const fs = require('fs').promises
-const path = require('path')
-const globby = require('globby')
-
-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}'
-]
-const GLOBBY_OPTIONS = {
- cwd: path.join(__dirname, '..'),
- gitignore: true
-}
-
-// Blame TC39... https://github.com/benjamingr/RegExp.escape/issues/37
-function regExpQuote(string) {
- return string.replace(/[$()*+-.?[\\\]^{|}]/g, '\\$&')
-}
-
-function regExpQuoteReplacement(string) {
- return string.replace(/\$/g, '$$')
-}
-
-async function replaceRecursively(file, oldVersion, newVersion) {
- const originalString = await fs.readFile(file, 'utf8')
- const newString = originalString.replace(
- new RegExp(regExpQuote(oldVersion), 'g'), regExpQuoteReplacement(newVersion)
- )
-
- // No need to move any further if the strings are identical
- if (originalString === newString) {
- return
- }
-
- if (VERBOSE) {
- console.log(`FILE: ${file}`)
- }
-
- if (DRY_RUN) {
- return
- }
-
- await fs.writeFile(file, newString, 'utf8')
-}
-
-async function main(args) {
- let [oldVersion, newVersion] = args
-
- if (!oldVersion || !newVersion) {
- console.error('USAGE: change-version old_version new_version [--verbose] [--dry[-run]]')
- console.error('Got arguments:', args)
- process.exit(1)
- }
-
- // Strip any leading `v` from arguments because otherwise we will end up with duplicate `v`s
- [oldVersion, newVersion] = [oldVersion, newVersion].map(arg => arg.startsWith('v') ? arg.slice(1) : arg)
-
- try {
- const files = await globby(GLOB, GLOBBY_OPTIONS)
-
- await Promise.all(files.map(file => replaceRecursively(file, oldVersion, newVersion)))
- } catch (error) {
- console.error(error)
- process.exit(1)
- }
-}
-
-main(process.argv.slice(2))