-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdateInfo.js
32 lines (26 loc) · 1.14 KB
/
updateInfo.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
const fs = require("fs")
const path = require("path")
// Read command-line arguments
const args = require("minimist")(process.argv.slice(2))
const params = args._.reduce((acc, param) => {
const [key, value] = param.split("=")
acc[key] = value
return acc
}, {})
const { name, author, description, source } = params
// Read package.json
const packageJsonPath = path.join(__dirname, "package.json")
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf8"))
const version = packageJson.version
// Read wiemantheme.theme.css
const targetPath = path.join(__dirname, "wiemantheme.theme.css")
let targetContent = fs.readFileSync(targetPath, "utf8")
// Replace placeholders
targetContent = targetContent.replace(/\${name}/g, name)
targetContent = targetContent.replace(/\${author}/g, author)
targetContent = targetContent.replace(/\${description}/g, description)
targetContent = targetContent.replace(/\${source}/g, source)
targetContent = targetContent.replace(/\${version}/g, version)
// Write updated content back to wiemantheme.theme.css
fs.writeFileSync(targetPath, targetContent, "utf8")
console.log(`> compiled with version v${version}`)