mirror of https://github.com/onivim/oni.git
38 lines
1.2 KiB
JavaScript
38 lines
1.2 KiB
JavaScript
// BuildSetupTemplate.js
|
|
//
|
|
// Helper script to insert template variables into the setup template
|
|
|
|
const path = require("path")
|
|
const fs = require("fs")
|
|
|
|
const _ = require("lodash")
|
|
const shelljs = require("shelljs")
|
|
|
|
const sourceFile = path.join(__dirname, "setup.template.iss")
|
|
const destFile = path.join(__dirname, "..", "dist", "setup.iss")
|
|
|
|
shelljs.rm(destFile)
|
|
|
|
shelljs.cp(sourceFile, destFile)
|
|
|
|
const packageJsonContents = fs.readFileSync(path.join(__dirname, "..", "package.json"))
|
|
const packageMeta = JSON.parse(packageJsonContents)
|
|
const { version, name } = packageMeta
|
|
const prodName = packageMeta.build.productName
|
|
|
|
// Replace template variables
|
|
|
|
const valuesToReplace = {
|
|
"AppName": prodName,
|
|
"AppExecutableName": `${prodName}.exe`,
|
|
"AppSetupExecutableName": `${prodName}-${version}-ia32-win`,
|
|
"Version": version,
|
|
"SourcePath": path.join(__dirname, "..", "dist", "win-ia32-unpacked", "*"),
|
|
"WizardImageFilePath": path.join(__dirname, "setup", "Oni_128.bmp"),
|
|
"WizardSmallImageFilePath": path.join(__dirname, "setup", "Oni_54.bmp")
|
|
}
|
|
|
|
_.keys(valuesToReplace).forEach((key) => {
|
|
shelljs.sed("-i", "{{" + key + "}}", valuesToReplace[key], destFile)
|
|
})
|