Skip to content

Commit

Permalink
chore: build env
Browse files Browse the repository at this point in the history
  • Loading branch information
billchurch committed Dec 2, 2024
1 parent dd6dafc commit beb99dd
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 8 deletions.
9 changes: 2 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
"test": "node test/index.test.js",
"build": "webpack --config scripts/webpack.config.js",
"prepublishOnly": "npm run build",
"release:first": "standard-version --first-release -a -s",
"release": "standard-version -a -s",
"release": "node scripts/release.js",
"release:first": "node scripts/release.js --first-release",
"lint": "eslint src test",
"lint:fix": "eslint src test --fix",
"clean": "rimraf dist",
Expand Down Expand Up @@ -53,10 +53,5 @@
"standard-version": "^9.5.0",
"webpack": "^5.93.0",
"webpack-cli": "^5.1.4"
},
"standard-version": {
"scripts": {
"postbump": "webpack --config scripts/webpack.config.js"
}
}
}
18 changes: 18 additions & 0 deletions scripts/release.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
const { execSync } = require('child_process')
const path = require('path')
const fs = require('fs')

// Get next version without bumping
const nextVersion = execSync('npx standard-version --dry-run --skip.bump')
.toString()
.match(/bumping version in package\.json from .* to (.*)/)[1]
.trim()

// Build webpack with new version to update README
execSync('webpack --config scripts/webpack.config.js', {
env: { ...process.env, NEXT_VERSION: nextVersion }
})

// Run standard-version for real
const args = process.argv.includes('--first-release') ? '--first-release' : ''
execSync(`npx standard-version ${args} -a -s`, { stdio: 'inherit' })
5 changes: 4 additions & 1 deletion scripts/webpack-readme-plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ const path = require('path')
class WebpackReadmePlugin {
apply(compiler) {
compiler.hooks.done.tap('WebpackReadmePlugin', () => {
const { version } = require('../package.json')
const version =
process.env.NEXT_VERSION || require('../package.json').version

// Use this version when updating the README CDN link
const readmePath = path.resolve(__dirname, '../README.md')

let readme = fs.readFileSync(readmePath, 'utf8')
Expand Down

0 comments on commit beb99dd

Please sign in to comment.