Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: twbs/bootstrap
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 6d8057636ac4bfb4f81b81fe0a52daf1c73ef0c6
Choose a base ref
..
head repository: twbs/bootstrap
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 13c031d53368b7f6e1954732b47a16e16781cc73
Choose a head ref
Showing with 32 additions and 12 deletions.
  1. +1 −2 .github/workflows/node-sass.yml
  2. +1 −1 .gitignore
  3. +30 −9 build/change-version.js
3 changes: 1 addition & 2 deletions .github/workflows/node-sass.yml
Original file line number Diff line number Diff line change
@@ -35,8 +35,7 @@ jobs:
npx --package node-sass@latest node-sass --output-style expanded --source-map true --source-map-contents true --precision 6 scss/ -o dist-sass/css/
ls -Al dist-sass/css
# Check that there are no Sass variables (`$`)
- name: Check built CSS files
- name: Check built CSS files for Sass variables
shell: bash
run: |
SASS_VARS_FOUND=$(find "dist-sass/css/" -type f -name "*.css" -print0 | xargs -0 --no-run-if-empty grep -F "\$" || true)
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -38,6 +38,6 @@ Thumbs.db
*.komodoproject

# Folders to ignore
/dist-sass/
/js/coverage/
/node_modules/
/dist-sass/
39 changes: 30 additions & 9 deletions build/change-version.js
Original file line number Diff line number Diff line change
@@ -35,9 +35,17 @@ function regExpQuoteReplacement(string) {

async function replaceRecursively(file, oldVersion, newVersion) {
const originalString = await fs.readFile(file, 'utf8')
const newString = originalString.replace(
new RegExp(regExpQuote(oldVersion), 'g'), regExpQuoteReplacement(newVersion)
)
const newString = originalString
.replace(
new RegExp(regExpQuote(oldVersion), 'g'),
regExpQuoteReplacement(newVersion)
)
// Also replace the version used by the rubygem,
// which is using periods (`.`) instead of hyphens (`-`)
.replace(
new RegExp(regExpQuote(oldVersion.replace(/-/g, '.')), 'g'),
regExpQuoteReplacement(newVersion.replace(/-/g, '.'))
)

// No need to move any further if the strings are identical
if (originalString === newString) {
@@ -55,22 +63,35 @@ async function replaceRecursively(file, oldVersion, newVersion) {
await fs.writeFile(file, newString, 'utf8')
}

function showUsage(args) {
console.error('USAGE: change-version old_version new_version [--verbose] [--dry[-run]]')
console.error('Got arguments:', args)
process.exit(1)
}

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)
showUsage(args)
}

// 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)
// Strip any leading `v` from arguments because
// otherwise we will end up with duplicate `v`s
[oldVersion, newVersion] = [oldVersion, newVersion].map(arg => {
return arg.startsWith('v') ? arg.slice(1) : arg
})

if (oldVersion === newVersion) {
showUsage(args)
}

try {
const files = await globby(GLOB, GLOBBY_OPTIONS)

await Promise.all(files.map(file => replaceRecursively(file, oldVersion, newVersion)))
await Promise.all(
files.map(file => replaceRecursively(file, oldVersion, newVersion))
)
} catch (error) {
console.error(error)
process.exit(1)