Skip to content

Commit

Permalink
Fix download path (#5)
Browse files Browse the repository at this point in the history
* change path for chmod

* package

* use cp insteadof mv

* package

* fix test
  • Loading branch information
kondoumh authored May 21, 2020
1 parent 3634782 commit fd6abd7
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
4 changes: 2 additions & 2 deletions src/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
12 changes: 6 additions & 6 deletions src/setup.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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`);
});
});

0 comments on commit fd6abd7

Please sign in to comment.