From 354a0cbf844eab2e4ac0caf3158f00f3345d0406 Mon Sep 17 00:00:00 2001 From: Thomas Nordquist Date: Thu, 7 Mar 2019 10:23:26 +0100 Subject: [PATCH] Update product name depending on package --- package.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/package.ts b/package.ts index f844d42..6402e55 100644 --- a/package.ts +++ b/package.ts @@ -81,11 +81,14 @@ async function executeBuild() { export interface BuildInfo { platform: 'win' | 'linux' | 'mac' - package: 'portable' | 'nsis' | 'appx' | 'AppImage' | 'snap' | 'dmg' | 'zip' | 'mas' | 'mas-dev' + package: Packages } +type Packages = 'portable' | 'nsis' | 'appx' | 'AppImage' | 'snap' | 'dmg' | 'zip' | 'mas' | 'mas-dev' + async function buildWithOptions(options: builder.CliOptions, buildInfo: BuildInfo) { fs.writeFileSync(path.join(options.projectDir!, 'buildOptions.json'), JSON.stringify(buildInfo)) + ensureAppNameForPackage(buildInfo.package) await builder.build({ ...options, @@ -93,6 +96,14 @@ async function buildWithOptions(options: builder.CliOptions, buildInfo: BuildInf }) } +// AppX must hav a different name since the store name is already taken (but not used) +function ensureAppNameForPackage(packageOption: Packages) { + const jsonLocation = path.join('build', 'clean', 'package.json') + const packageJson = JSON.parse(fs.readFileSync(jsonLocation).toString()) + packageJson.build.productName = packageOption === 'appx' ? 'MQTT-Explorer' : 'MQTT Explorer' + fs.writeFileSync(jsonLocation, JSON.stringify(packageJson, undefined, ' ')) +} + function build() { try { executeBuild()