From 4ee4be63159472d621abc30d5fbe017d7a88981a Mon Sep 17 00:00:00 2001 From: develar Date: Fri, 5 Apr 2019 10:00:33 +0200 Subject: [PATCH] feat(portable): `unpackDirName` option for portable Close #3799 --- packages/app-builder-lib/scheme.json | 4 ++++ packages/app-builder-lib/src/targets/nsis/NsisTarget.ts | 5 +++-- packages/app-builder-lib/src/targets/nsis/nsisOptions.ts | 7 +++++++ test/src/windows/portableTest.ts | 1 + 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/packages/app-builder-lib/scheme.json b/packages/app-builder-lib/scheme.json index 09bde0351eb..a42f051a857 100644 --- a/packages/app-builder-lib/scheme.json +++ b/packages/app-builder-lib/scheme.json @@ -3797,6 +3797,10 @@ "default": true, "description": "If `warningsAsErrors` is `true` (default): NSIS will treat warnings as errors. If `warningsAsErrors` is `false`: NSIS will allow warnings.", "type": "boolean" + }, + "unpackDirName": { + "description": "The unpack directory name in [TEMP](https://www.askvg.com/where-does-windows-store-temporary-files-and-how-to-change-temp-folder-location/) directory.\n\nDefaults to [uuid](https://github.com/segmentio/ksuid) of build (changed on each build of portable executable).", + "type": "string" } }, "title": "PortableOptions", diff --git a/packages/app-builder-lib/src/targets/nsis/NsisTarget.ts b/packages/app-builder-lib/src/targets/nsis/NsisTarget.ts index fca2baa7a3c..36d5691f116 100644 --- a/packages/app-builder-lib/src/targets/nsis/NsisTarget.ts +++ b/packages/app-builder-lib/src/targets/nsis/NsisTarget.ts @@ -227,8 +227,9 @@ export class NsisTarget extends Target { this.configureDefinesForAllTypeOfInstaller(defines) if (isPortable) { - defines.REQUEST_EXECUTION_LEVEL = (options as PortableOptions).requestExecutionLevel || "user" - defines.UNPACK_DIR_NAME = await executeAppBuilder(["ksuid"]) + const portableOptions = options as PortableOptions + defines.REQUEST_EXECUTION_LEVEL = portableOptions.requestExecutionLevel || "user" + defines.UNPACK_DIR_NAME = portableOptions.unpackDirName || (await executeAppBuilder(["ksuid"])) } else { await this.configureDefines(oneClick, defines) diff --git a/packages/app-builder-lib/src/targets/nsis/nsisOptions.ts b/packages/app-builder-lib/src/targets/nsis/nsisOptions.ts index e72358b183a..5fa9bbafe50 100644 --- a/packages/app-builder-lib/src/targets/nsis/nsisOptions.ts +++ b/packages/app-builder-lib/src/targets/nsis/nsisOptions.ts @@ -167,6 +167,13 @@ export interface PortableOptions extends TargetSpecificOptions, CommonNsisOption * @default user */ readonly requestExecutionLevel?: "user" | "highest" | "admin" + + /** + * The unpack directory name in [TEMP](https://www.askvg.com/where-does-windows-store-temporary-files-and-how-to-change-temp-folder-location/) directory. + * + * Defaults to [uuid](https://github.com/segmentio/ksuid) of build (changed on each build of portable executable). + */ + readonly unpackDirName?: string } /** diff --git a/test/src/windows/portableTest.ts b/test/src/windows/portableTest.ts index ba7c066e2dd..17da47c3cd5 100644 --- a/test/src/windows/portableTest.ts +++ b/test/src/windows/portableTest.ts @@ -19,6 +19,7 @@ test.ifAll.ifDevOrWinCi("portable zip", app({ publish: null, portable: { useZip: true, + unpackDirName: "0ujssxh0cECutqzMgbtXSGnjorm", }, compression: "normal", }