From 8c9699998e6716018f7ec33ad170c165ccb44d3e Mon Sep 17 00:00:00 2001 From: Imran Ismail Date: Tue, 31 Mar 2020 02:16:56 +0800 Subject: [PATCH] Set proper file permissions once downloaded --- __tests__/installer.test.ts | 4 +++- src/installer.ts | 8 ++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/__tests__/installer.test.ts b/__tests__/installer.test.ts index d5bc936..a1480f2 100644 --- a/__tests__/installer.test.ts +++ b/__tests__/installer.test.ts @@ -34,6 +34,7 @@ describe('installer tests', () => { expect(fs.existsSync(path.join(kustomizeDir, 'kustomize.exe'))).toBe(true); } else { expect(fs.existsSync(path.join(kustomizeDir, 'kustomize'))).toBe(true); + expect(() => fs.accessSync(path.join(kustomizeDir, 'kustomize'), fs.constants.X_OK)).not.toThrow() } }, 100000); @@ -47,6 +48,7 @@ describe('installer tests', () => { expect(fs.existsSync(path.join(kustomizeDir, 'kustomize.exe'))).toBe(true); } else { expect(fs.existsSync(path.join(kustomizeDir, 'kustomize'))).toBe(true); + expect(() => fs.accessSync(path.join(kustomizeDir, 'kustomize'), fs.constants.X_OK)).not.toThrow() } }, 100000) @@ -60,6 +62,7 @@ describe('installer tests', () => { expect(fs.existsSync(path.join(kustomizeDir, 'kustomize.exe'))).toBe(true); } else { expect(fs.existsSync(path.join(kustomizeDir, 'kustomize'))).toBe(true); + expect(() => fs.accessSync(path.join(kustomizeDir, 'kustomize'), fs.constants.X_OK)).not.toThrow() } }, 100000) @@ -95,7 +98,6 @@ describe('installer tests', () => { fs.writeFileSync(`${kustomizeDir}.complete`, 'hello'); await installer.getKustomize('3.0.0'); - // await installer.getKustomize('3.0'); await installer.getKustomize('3.0'); }); }); \ No newline at end of file diff --git a/src/installer.ts b/src/installer.ts index f46c459..113215a 100644 --- a/src/installer.ts +++ b/src/installer.ts @@ -6,6 +6,7 @@ import * as restm from 'typed-rest-client/RestClient'; import * as os from 'os'; import * as path from 'path'; import * as semver from 'semver'; +import * as fs from 'fs' let osPlat: string = os.platform(); let osArch: string = os.arch(); @@ -194,5 +195,12 @@ async function acquireKustomize(version: string): Promise { toolPath = path.join(toolPath, toolFilename) } + switch (osPlat) { + case 'linux': + case 'darwin': + fs.chmodSync(toolPath, 0o755) + break; + } + return await tc.cacheFile(toolPath, toolFilename, toolName, version); } \ No newline at end of file