Skip to content

Commit

Permalink
build(sanity): use correct file extensions when replacing version str…
Browse files Browse the repository at this point in the history
…ings
  • Loading branch information
mariuslundgard committed Sep 28, 2022
1 parent e2f2c4e commit b47ea65
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 27 deletions.
30 changes: 14 additions & 16 deletions packages/sanity/scripts/writeRequiredUIVersion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,20 +49,18 @@ if (!v) {

const version = `${v.major}.${v.minor}.${v.patch}`

globby([path.join(__dirname, '../lib/**/*.cjs'), path.join(__dirname, '../lib/**/*.js')]).then(
(files) => {
for (const file of files) {
const buf = fs.readFileSync(file, 'utf8')
fs.writeFileSync(
file,
buf
.toString()
.replace(
/REQUIRED_UI_VERSION = "0\.0\.0-development"/g,
`REQUIRED_UI_VERSION = "${version}"`
),
'utf8'
)
}
globby([
path.resolve(__dirname, '../lib/**/*.js'),
path.resolve(__dirname, '../lib/**/*.mjs'),
]).then((files) => {
for (const file of files) {
const buf = fs.readFileSync(file, 'utf8')
fs.writeFileSync(
file,
buf
.toString()
.replace('REQUIRED_UI_VERSION="0.0.0-development"', `REQUIRED_UI_VERSION="${version}"`),
'utf8'
)
}
)
})
23 changes: 12 additions & 11 deletions packages/sanity/scripts/writeVersion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,16 @@ import path from 'path'
import globby from 'globby'
import {version} from '../package.json'

globby([path.join(__dirname, '../lib/**/*.cjs'), path.join(__dirname, '../lib/**/*.js')]).then(
(files) => {
for (const file of files) {
const buf = fs.readFileSync(file, 'utf8')
fs.writeFileSync(
file,
buf.toString().replace(/"0\.0\.0-development"/g, `"${version}"`),
'utf8'
)
}
globby([
path.resolve(__dirname, '../lib/**/*.js'),
path.resolve(__dirname, '../lib/**/*.mjs'),
]).then((files) => {
for (const file of files) {
const buf = fs.readFileSync(file, 'utf8')
fs.writeFileSync(
file,
buf.toString().replace('SANITY_VERSION="0.0.0-development"', `SANITY_VERSION="${version}"`),
'utf8'
)
}
)
})

0 comments on commit b47ea65

Please sign in to comment.