3
0
Fork 0
mirror of https://code.forgejo.org/actions/cache.git synced 2025-08-08 14:21:23 +00:00

Use path.sep in path replace

This commit is contained in:
Aiqiao Yan 2020-04-13 12:20:27 -04:00
parent 7c7d003bbb
commit 9fe7ad8b07
4 changed files with 17 additions and 149 deletions

View file

@ -28,7 +28,7 @@ async function getTarPath(args: string[]): Promise<string> {
const systemTar = `${process.env["windir"]}\\System32\\tar.exe`;
if (existsSync(systemTar)) {
return systemTar;
} else if (isGnuTar()) {
} else if (await isGnuTar()) {
args.push("--force-local");
}
}
@ -52,9 +52,9 @@ export async function extractTar(
const args = [
"-xz",
"-f",
archivePath?.replace(/\\/g, "/"),
archivePath.replace(new RegExp("\\" + path.sep, "g"), "/"),
"-C",
targetDirectory?.replace(/\\/g, "/")
targetDirectory.replace(new RegExp("\\" + path.sep, "g"), "/")
];
await execTar(args);
}
@ -66,9 +66,9 @@ export async function createTar(
const args = [
"-cz",
"-f",
archivePath?.replace(/\\/g, "/"),
archivePath.replace(new RegExp("\\" + path.sep, "g"), "/"),
"-C",
sourceDirectory?.replace(/\\/g, "/"),
sourceDirectory.replace(new RegExp("\\" + path.sep, "g"), "/"),
"."
];
await execTar(args);