Skip to content

Commit

Permalink
use fs-extra.moveSync
Browse files Browse the repository at this point in the history
Signed-off-by: Rajat Jindal <[email protected]>
  • Loading branch information
rajatjindal committed Jan 17, 2023
1 parent f7d8b6e commit acb450e
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 4 deletions.
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: "engineerd/configurator"
description: "Easy and cross-platform action to download, extract, and add to path statically compiled tools."
author: "Engineerd"
author: "engineerd"
inputs:
name:
description: "Name your tool will be configured with"
Expand Down
67 changes: 67 additions & 0 deletions package-lock.json

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

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"@actions/github": "^4.0.0",
"@actions/io": "^1.0.2",
"@actions/tool-cache": "^1.6.1",
"fs-extra": "^10.0.0",
"mustache": "^4.0.1",
"semver": "^7.3.2",
"uuid": "^8.3.2"
Expand All @@ -46,4 +47,4 @@
"ts-node": "^8.8.1",
"typescript": "^3.5.1"
}
}
}
6 changes: 5 additions & 1 deletion src/configurator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import * as os from "os";
import { getTag } from "./release";
import Mustache from "mustache";
import { v4 as uuidv4 } from "uuid";
import * as fs from "fs-extra";

const NameInput: string = "name";
const URLInput: string = "url";
Expand Down Expand Up @@ -136,7 +137,10 @@ export class Configurator {
async moveToPath(downloadPath: string) {
let toolPath = binPath();
await io.mkdirP(toolPath);
await io.mv(downloadPath, path.join(toolPath, this.name));
const dest = path.join(toolPath, this.name);
if (!fs.existsSync(dest)) {
fs.moveSync(downloadPath, dest);
}

if (process.platform !== "win32") {
await exec.exec("chmod", ["+x", path.join(toolPath, this.name)]);
Expand Down
2 changes: 1 addition & 1 deletion test/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import "mocha";
import * as chai from "chai";
import { assert, expect } from "chai";
import * as cfg from "../src/configurator";
import * as fs from "fs";
import * as fs from "fs-extra";
import * as rimraf from "rimraf";
import { getTag } from "../src/release";

Expand Down

0 comments on commit acb450e

Please sign in to comment.