Skip to content

Commit

Permalink
feat: allow to update existing asdf
Browse files Browse the repository at this point in the history
  • Loading branch information
exKAZUu committed Dec 28, 2021
1 parent b797cb8 commit 7087a15
Show file tree
Hide file tree
Showing 5 changed files with 121 additions and 76 deletions.
45 changes: 27 additions & 18 deletions install/main.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 19 additions & 10 deletions lib/setup/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as core from "@actions/core";
import * as exec from "@actions/exec";
import * as io from "@actions/io";
import * as fs from "fs";
import * as os from "os";
import * as path from "path";

Expand All @@ -14,15 +15,23 @@ export async function setupAsdf(): Promise<void> {
core.exportVariable("ASDF_DATA_DIR", asdfDir);
core.addPath(`${asdfDir}/bin`);
core.addPath(`${asdfDir}/shims`);
core.info(`Cloning asdf into ASDF_DIR: ${asdfDir}`);
const branch = core.getInput("asdf_branch", { required: true });
await exec.exec("git", [
"clone",
"--depth",
"1",
"--branch",
branch,
"https://github.com/asdf-vm/asdf.git",
asdfDir,
]);
if (fs.existsSync(asdfDir)) {
core.info(`Updating asdf on ASDF_DIR: ${asdfDir}`);
await exec.exec("git", ["fetch", "--depth", "1"], { cwd: asdfDir });
await exec.exec("git", ["checkout", "-B", branch, "origin"], {
cwd: asdfDir,
});
} else {
core.info(`Cloning asdf into ASDF_DIR: ${asdfDir}`);
await exec.exec("git", [
"clone",
"--depth",
"1",
"--branch",
branch,
"https://github.com/asdf-vm/asdf.git",
asdfDir,
]);
}
}
39 changes: 24 additions & 15 deletions plugin-test/main.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

45 changes: 27 additions & 18 deletions plugins-add/main.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

39 changes: 24 additions & 15 deletions setup/main.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 7087a15

Please sign in to comment.