diff --git a/dist/index.js b/dist/index.js index a9c930f..22e759f 100644 --- a/dist/index.js +++ b/dist/index.js @@ -4333,8 +4333,8 @@ async function extract(downloadPath) { async function install(downloadPath, filename) { const binPath = `${os.homedir}/bin`; await io.mkdirP(binPath); - await exec.exec("chmod", ["+x", downloadPath]); - await io.mv(downloadPath, path.join(binPath, filename)); + await io.cp(downloadPath, path.join(binPath, filename)); + await exec.exec("chmod", ["+x", `${binPath}/${filename}`]); core.addPath(binPath); } diff --git a/src/setup.js b/src/setup.js index 85caa9e..a436edb 100644 --- a/src/setup.js +++ b/src/setup.js @@ -39,8 +39,8 @@ async function extract(downloadPath) { async function install(downloadPath, filename) { const binPath = `${os.homedir}/bin`; await io.mkdirP(binPath); - await exec.exec("chmod", ["+x", downloadPath]); - await io.mv(downloadPath, path.join(binPath, filename)); + await io.cp(downloadPath, path.join(binPath, filename)); + await exec.exec("chmod", ["+x", `${binPath}/${filename}`]); core.addPath(binPath); } diff --git a/src/setup.test.js b/src/setup.test.js index dba220c..7ee75e1 100644 --- a/src/setup.test.js +++ b/src/setup.test.js @@ -8,7 +8,7 @@ const { installKubectl, installHelm, installHelmfile } = require("./setup"); describe('Normal', () => { let downloadToolMock; - let mvMock; + let cpMock; beforeEach(() => { downloadToolMock = jest.fn(async (url) => { console.log("fake download"); @@ -21,26 +21,26 @@ describe('Normal', () => { io.mkdirP = jest.fn(async (dir) => { console.log(dir); }); - mvMock = jest.fn(async (source, dest) => { + cpMock = jest.fn(async (source, dest) => { console.log(source + " : " + dest); }); - io.mv = mvMock; + io.cp = cpMock; exec.exec = jest.fn(async (command, param) => {}); addPathMock = jest.fn(async (path) => {}); }); test('Test installKubectl', async () => { await installKubectl("1.14.6", "2019-08-22"); expect(downloadToolMock.mock.calls[0][0]).toBe("https://amazon-eks.s3-us-west-2.amazonaws.com/1.14.6/2019-08-22/bin/linux/amd64/kubectl"); - expect(mvMock.mock.calls[0][1]).toBe(`${os.homedir}${sp}bin${sp}kubectl`); + expect(cpMock.mock.calls[0][1]).toBe(`${os.homedir}${sp}bin${sp}kubectl`); }); test('Test installHelm', async () => { await installHelm("v3.0.3"); expect(downloadToolMock.mock.calls[0][0]).toBe("https://get.helm.sh/helm-v3.0.3-linux-amd64.tar.gz"); - expect(mvMock.mock.calls[0][1]).toBe(`${os.homedir}${sp}bin${sp}helm`); + expect(cpMock.mock.calls[0][1]).toBe(`${os.homedir}${sp}bin${sp}helm`); }); test('Test installHelmfile', async () => { await installHelmfile("v0.98.3"); expect(downloadToolMock.mock.calls[0][0]).toBe("https://github.com/roboll/helmfile/releases/download/v0.98.3/helmfile_linux_amd64"); - expect(mvMock.mock.calls[0][1]).toBe(`${os.homedir}${sp}bin${sp}helmfile`); + expect(cpMock.mock.calls[0][1]).toBe(`${os.homedir}${sp}bin${sp}helmfile`); }); });