Skip to content

Commit 8271ae8

Browse files
committed
use path.join
1 parent 30ab882 commit 8271ae8

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

src/main.ts

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import * as tc from "@actions/tool-cache";
88
import fs from "fs";
99
import path from "path";
1010
import * as os from "os";
11-
import { join } from "node:path";
1211
import * as semver from "semver";
1312

1413
async function move(src: string, dest: string) {
@@ -99,21 +98,21 @@ async function downloadAndCacheTypst(version: string) {
9998
found = await tc.extractTar(found, undefined, "xJ");
10099
core.debug(`Extracted archive for Typst version: '${version}'.`);
101100
}
102-
found = join(found, folder);
101+
found = path.join(found, folder);
103102
found = await tc.cacheDir(found, "typst", version);
104103
core.info(`Typst ${version} added to cache at '${found}'.`);
105104
return found;
106105
}
107106

108107
const TYPST_PACKAGES_DIR = {
109108
linux: () =>
110-
join(
109+
path.join(
111110
process.env.XDG_CACHE_HOME ||
112-
(os.homedir() ? join(os.homedir(), ".cache") : undefined)!,
111+
(os.homedir() ? path.join(os.homedir(), ".cache") : undefined)!,
113112
"typst/packages"
114113
),
115-
darwin: () => join(process.env.HOME!, "Library/Caches", "typst/packages"),
116-
win32: () => join(process.env.LOCALAPPDATA!, "typst/packages"),
114+
darwin: () => path.join(process.env.HOME!, "Library/Caches", "typst/packages"),
115+
win32: () => path.join(process.env.LOCALAPPDATA!, "typst/packages"),
117116
}[process.platform as string]!();
118117

119118
async function cachePackages(cachePackage: string) {
@@ -184,7 +183,7 @@ async function downloadLocalPackages(packages: {
184183
await Promise.all(
185184
Object.entries(packages.local).map(async ([key, value]) => {
186185
core.info(`Downloading package: '${key}' from '${value}'.`);
187-
const packageDir = join(packagesDir, key);
186+
const packageDir = path.join(packagesDir, key);
188187
if (!fs.existsSync(packageDir)) {
189188
fs.mkdirSync(packageDir);
190189
core.debug(`Created directory for package: '${packageDir}'.`);
@@ -220,14 +219,14 @@ async function downloadLocalPackages(packages: {
220219
const innerPath = path.join(packageResponse, dirContent[0]);
221220
const stats = fs.statSync(innerPath);
222221
if (stats.isDirectory()) {
223-
const packageVersion = getPackageVersion(join(innerPath, "typst.toml"));
224-
move(innerPath, join(packageDir, packageVersion));
222+
const packageVersion = getPackageVersion(path.join(innerPath, "typst.toml"));
223+
move(innerPath, path.join(packageDir, packageVersion));
225224
}
226225
} else {
227226
const packageVersion = getPackageVersion(
228-
join(packageResponse, "typst.toml")
227+
path.join(packageResponse, "typst.toml")
229228
);
230-
move(packageResponse, join(packageDir, packageVersion));
229+
move(packageResponse, path.join(packageDir, packageVersion));
231230
}
232231
core.info(`Downloaded ${key} to ${packageDir}`);
233232
})

0 commit comments

Comments
 (0)