From 3fcdb9f0998128ee8455fa94ebca326ae4f0833c Mon Sep 17 00:00:00 2001 From: Andrew Kahr <22359829+AndrewKahr@users.noreply.github.com> Date: Sun, 18 Feb 2024 02:33:51 -0800 Subject: [PATCH] Use nullish coalescing operator --- dist/index.js | Bin 22302632 -> 22302634 bytes dist/index.js.map | Bin 14796226 -> 14796228 bytes src/model/build-parameters.ts | 4 +- src/model/input.ts | 76 +++++++++++++++++----------------- 4 files changed, 40 insertions(+), 40 deletions(-) diff --git a/dist/index.js b/dist/index.js index 9c31a59cd0d1f9373fe2dbe8a049befcb7ff5fd2..0a5c8f1d155e60f031378a522b67fd8c4b85bce4 100644 GIT binary patch delta 2048 zcmZY9X;f8J0EXcOZe|=16afc71O+D?QRJe66XI-YnIk7> zrFaAud6t-bcTE?Rnwh#TUTuPGlQJ{IJ2^Q#CL=dzk#&`sHg-jsNz!^iwFz}56?+w( zDl=;u?$nIUD>nnQ>?$|&bd7bHtbexKovw@bo^zQcnv73&1>5Cy#>1YiF&*u;y=Hjh z-ewgh#a~BH%3PR{l{0_##p81;jN{Ut2z#u;q&5zcD$P(0R#uwa#>v7;MOikW z#)Q}n)u#WYl~8-8+Dva8%-nCbYT#dI!kmR=9yYF~@%dpkuf~kl>SZ4!?|(CqcGm$j zrQyh!L|>a-XM&2N51L3f?Myq=@TH4N4w;aKzsJ$TX1AYSZ%*dijNAn|4Ij{X;<%43 zJz^&7mX@_3ky8;fxxZbA-naWihg65NWVxDB`C4lKiR ztiVd#iB-4@cOwt^xCg7T25WII?!!71U_I`~18`yk9>hbico>i1Q9Oo?cpOh)6Q0CV zcpA^(Sv-g5@d7sEMQp)VY{N@<8Lyxa+wm%PU?+CrH5B1>6r%*YQHnCWfjuaP3wu$4 zN>pJVs<9t6IDmsVgg0>*M^KA8yoI;%4vyj&-bFo*<2}5O4{!n>;v`PtBYce0_ynKg zGn~Qa_yS+zD}0S_@GZ{bJA98Ha1KA>C;W_G@GE}9@Aw1f@hASm-)sHr+zOz$D@_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AP2dagFMW|Jj_Qv7T`uK#7(#vi?A3=uoSmo8J1%OR^nFNhTCxmR^d*p#$8y0wJ5+k z6kNt?7SX6_|bqy1keP7 zX0#xPR&2$CXu~$NqXQ3NJ9eNG591L$ik(nAhFy3ZPvA-H##4A2U3do1;yFBz7w{rp z!pqo$SMVxc!|T|KZoGkgcoT1-2XEsYgzzr*;{e`6FW$!oIEX{|5Pb-vABXV~KE@~b w6rbS;KF3jffiH0kU*T(fgKsf_<2Zqn_zvIW6n?;u_z6GbmrzIh>6uyo0o6XExBvhE diff --git a/src/model/build-parameters.ts b/src/model/build-parameters.ts index 30c4ba6a..42c05915 100644 --- a/src/model/build-parameters.ts +++ b/src/model/build-parameters.ts @@ -170,7 +170,7 @@ class BuildParameters { customParameters: Input.customParameters, sshAgent: Input.sshAgent, sshPublicKeysDirectoryPath: Input.sshPublicKeysDirectoryPath, - gitPrivateToken: Input.gitPrivateToken || (await GithubCliReader.GetGitHubAuthToken()), + gitPrivateToken: Input.gitPrivateToken ?? (await GithubCliReader.GetGitHubAuthToken()), runAsHostUser: Input.runAsHostUser, chownFilesTo: Input.chownFilesTo, dockerCpuLimit: Input.dockerCpuLimit, @@ -192,7 +192,7 @@ class BuildParameters { branch: Input.branch.replace('/head', '') || (await GitRepoReader.GetBranch()), cloudRunnerBranch: CloudRunnerOptions.cloudRunnerBranch.split('/').reverse()[0], cloudRunnerDebug: CloudRunnerOptions.cloudRunnerDebug, - githubRepo: Input.githubRepo || (await GitRepoReader.GetRemote()) || 'game-ci/unity-builder', + githubRepo: (Input.githubRepo ?? (await GitRepoReader.GetRemote())) || 'game-ci/unity-builder', isCliMode: Cli.isCliMode, awsStackName: CloudRunnerOptions.awsStackName, gitSha: Input.gitSha, diff --git a/src/model/input.ts b/src/model/input.ts index 3aba0200..7d772a22 100644 --- a/src/model/input.ts +++ b/src/model/input.ts @@ -46,11 +46,11 @@ class Input { } static get region(): string { - return Input.getInput('region') || 'eu-west-2'; + return Input.getInput('region') ?? 'eu-west-2'; } static get githubRepo(): string | undefined { - return Input.getInput('GITHUB_REPOSITORY') || Input.getInput('GITHUB_REPO') || undefined; + return Input.getInput('GITHUB_REPOSITORY') ?? Input.getInput('GITHUB_REPO') ?? undefined; } static get branch(): string { @@ -74,19 +74,19 @@ class Input { } static get runNumber(): string { - return Input.getInput('GITHUB_RUN_NUMBER') || '0'; + return Input.getInput('GITHUB_RUN_NUMBER') ?? '0'; } static get targetPlatform(): string { - return Input.getInput('targetPlatform') || Platform.default; + return Input.getInput('targetPlatform') ?? Platform.default; } static get unityVersion(): string { - return Input.getInput('unityVersion') || 'auto'; + return Input.getInput('unityVersion') ?? 'auto'; } static get customImage(): string { - return Input.getInput('customImage') || ''; + return Input.getInput('customImage') ?? ''; } static get projectPath(): string { @@ -108,85 +108,85 @@ class Input { } static get runnerTempPath(): string { - return Input.getInput('RUNNER_TEMP') || ''; + return Input.getInput('RUNNER_TEMP') ?? ''; } static get buildName(): string { - return Input.getInput('buildName') || Input.targetPlatform; + return Input.getInput('buildName') ?? Input.targetPlatform; } static get buildsPath(): string { - return Input.getInput('buildsPath') || 'build'; + return Input.getInput('buildsPath') ?? 'build'; } static get unityLicensingServer(): string { - return Input.getInput('unityLicensingServer') || ''; + return Input.getInput('unityLicensingServer') ?? ''; } static get buildMethod(): string { - return Input.getInput('buildMethod') || ''; // Processed in docker file + return Input.getInput('buildMethod') ?? ''; // Processed in docker file } static get manualExit(): boolean { - const input = Input.getInput('manualExit') || false; + const input = Input.getInput('manualExit') ?? false; return input === 'true'; } static get customParameters(): string { - return Input.getInput('customParameters') || ''; + return Input.getInput('customParameters') ?? ''; } static get versioningStrategy(): string { - return Input.getInput('versioning') || 'Semantic'; + return Input.getInput('versioning') ?? 'Semantic'; } static get specifiedVersion(): string { - return Input.getInput('version') || ''; + return Input.getInput('version') ?? ''; } static get androidVersionCode(): string { - return Input.getInput('androidVersionCode') || ''; + return Input.getInput('androidVersionCode') ?? ''; } static get androidExportType(): string { - return Input.getInput('androidExportType') || 'androidPackage'; + return Input.getInput('androidExportType') ?? 'androidPackage'; } static get androidKeystoreName(): string { - return Input.getInput('androidKeystoreName') || ''; + return Input.getInput('androidKeystoreName') ?? ''; } static get androidKeystoreBase64(): string { - return Input.getInput('androidKeystoreBase64') || ''; + return Input.getInput('androidKeystoreBase64') ?? ''; } static get androidKeystorePass(): string { - return Input.getInput('androidKeystorePass') || ''; + return Input.getInput('androidKeystorePass') ?? ''; } static get androidKeyaliasName(): string { - return Input.getInput('androidKeyaliasName') || ''; + return Input.getInput('androidKeyaliasName') ?? ''; } static get androidKeyaliasPass(): string { - return Input.getInput('androidKeyaliasPass') || ''; + return Input.getInput('androidKeyaliasPass') ?? ''; } static get androidTargetSdkVersion(): string { - return Input.getInput('androidTargetSdkVersion') || ''; + return Input.getInput('androidTargetSdkVersion') ?? ''; } static get androidSymbolType(): string { - return Input.getInput('androidSymbolType') || 'none'; + return Input.getInput('androidSymbolType') ?? 'none'; } static get sshAgent(): string { - return Input.getInput('sshAgent') || ''; + return Input.getInput('sshAgent') ?? ''; } static get sshPublicKeysDirectoryPath(): string { - return Input.getInput('sshPublicKeysDirectoryPath') || ''; + return Input.getInput('sshPublicKeysDirectoryPath') ?? ''; } static get gitPrivateToken(): string | undefined { @@ -194,27 +194,27 @@ class Input { } static get runAsHostUser(): string { - return Input.getInput('runAsHostUser')?.toLowerCase() || 'false'; + return Input.getInput('runAsHostUser')?.toLowerCase() ?? 'false'; } static get chownFilesTo() { - return Input.getInput('chownFilesTo') || ''; + return Input.getInput('chownFilesTo') ?? ''; } static get allowDirtyBuild(): boolean { - const input = Input.getInput('allowDirtyBuild') || false; + const input = Input.getInput('allowDirtyBuild') ?? false; return input === 'true'; } static get cacheUnityInstallationOnMac(): boolean { - const input = Input.getInput('cacheUnityInstallationOnMac') || false; + const input = Input.getInput('cacheUnityInstallationOnMac') ?? false; return input === 'true'; } static get unityHubVersionOnMac(): string { - const input = Input.getInput('unityHubVersionOnMac') || ''; + const input = Input.getInput('unityHubVersionOnMac') ?? ''; return input !== '' ? input : ''; } @@ -228,11 +228,11 @@ class Input { } static get dockerWorkspacePath(): string { - return Input.getInput('dockerWorkspacePath') || '/github/workspace'; + return Input.getInput('dockerWorkspacePath') ?? '/github/workspace'; } static get dockerCpuLimit(): string { - return Input.getInput('dockerCpuLimit') || os.cpus().length.toString(); + return Input.getInput('dockerCpuLimit') ?? os.cpus().length.toString(); } static get dockerMemoryLimit(): string { @@ -252,24 +252,24 @@ class Input { } return ( - Input.getInput('dockerMemoryLimit') || `${Math.floor((os.totalmem() / bytesInMegabyte) * memoryMultiplier)}m` + Input.getInput('dockerMemoryLimit') ?? `${Math.floor((os.totalmem() / bytesInMegabyte) * memoryMultiplier)}m` ); } static get dockerIsolationMode(): string { - return Input.getInput('dockerIsolationMode') || 'default'; + return Input.getInput('dockerIsolationMode') ?? 'default'; } static get containerRegistryRepository(): string { - return Input.getInput('containerRegistryRepository') || 'unityci/editor'; + return Input.getInput('containerRegistryRepository') ?? 'unityci/editor'; } static get containerRegistryImageVersion(): string { - return Input.getInput('containerRegistryImageVersion') || '3'; + return Input.getInput('containerRegistryImageVersion') ?? '3'; } static get skipActivation(): string { - return Input.getInput('skipActivation')?.toLowerCase() || 'false'; + return Input.getInput('skipActivation')?.toLowerCase() ?? 'false'; } public static ToEnvVarFormat(input: string) {