Skip to content

Commit

Permalink
[skip ci] prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
jcbhmr authored Jan 25, 2024
1 parent 0e1b93f commit d24c990
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 19 deletions.
22 changes: 11 additions & 11 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ import * as cache from "@actions/cache";
import * as core from "@actions/core";
import * as github from "@actions/github";
import * as tc from "@actions/tool-cache";
import * as glob from "@actions/glob"
import * as glob from "@actions/glob";
import { join } from "node:path";
import * as semver from "semver";
import { createUnauthenticatedAuth } from "@octokit/auth-unauthenticated";
import { xdgCache } from "xdg-basedir";

const token = core.getInput("typst-token")
const token = core.getInput("typst-token");
const octokit = token
? github.getOctokit(token)
: github.getOctokit(undefined!, {
Expand Down Expand Up @@ -37,7 +37,7 @@ core.debug(`Resolved version: v${version}`);
if (!version) throw new DOMException(`${versionRaw} resolved to ${version}`);

let found = tc.find("typst", version);
let cacheHit = !!found
let cacheHit = !!found;

if (!found) {
const target = {
Expand Down Expand Up @@ -81,13 +81,13 @@ if (core.getBooleanInput("cache")) {
darwin: () => join(process.env.HOME!, "Library/Caches", "typst/packages"),
win32: () => join(process.env.LOCALAPPDATA!, "typst/packages"),
}[process.platform as string]!();
const hash = await glob.hashFiles("**/*.typ")
const primaryKey = `typst-packages-cache-${process.env.RUNNER_OS}-${hash}`
core.saveState("cache-primary-key", primaryKey)
core.info(`Restoring ${cacheDir} with key ${primaryKey}`)
const hitKey = cache.restoreCache([cacheDir], primaryKey)
core.saveState("cache-hit-key", hitKey)
cacheHit ||= !!hitKey
const hash = await glob.hashFiles("**/*.typ");
const primaryKey = `typst-packages-cache-${process.env.RUNNER_OS}-${hash}`;
core.saveState("cache-primary-key", primaryKey);
core.info(`Restoring ${cacheDir} with key ${primaryKey}`);
const hitKey = cache.restoreCache([cacheDir], primaryKey);
core.saveState("cache-hit-key", hitKey);
cacheHit ||= !!hitKey;
}

core.setOutput("cache-hit", cacheHit)
core.setOutput("cache-hit", cacheHit);
14 changes: 8 additions & 6 deletions src/post.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env node
import * as cache from "@actions/cache";
import * as core from "@actions/core";
import * as glob from "@actions/glob"
import * as glob from "@actions/glob";
import { join } from "node:path";
import { xdgCache } from "xdg-basedir";

Expand All @@ -11,12 +11,14 @@ if (core.getBooleanInput("cache")) {
darwin: () => join(process.env.HOME!, "Library/Caches", "typst/packages"),
win32: () => join(process.env.LOCALAPPDATA!, "typst/packages"),
}[process.platform as string]!();
const primaryKey = core.getState("cache-primary-key")
const hitKey = core.getState("cache-hit-key")
const primaryKey = core.getState("cache-primary-key");
const hitKey = core.getState("cache-hit-key");
if (hitKey) {
core.info(`Successfully restored ${cacheDir} with key ${hitKey}. Not saving cache.`)
core.info(
`Successfully restored ${cacheDir} with key ${hitKey}. Not saving cache.`,
);
} else {
core.info(`Saving ${cacheDir} with key ${primaryKey}`)
cache.saveCache([cacheDir], primaryKey)
core.info(`Saving ${cacheDir} with key ${primaryKey}`);
cache.saveCache([cacheDir], primaryKey);
}
}
4 changes: 2 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
"skipLibCheck": true,
"strict": true,
"noFallthroughCasesInSwitch": true,
"forceConsistentCasingInFileNames": true
}
"forceConsistentCasingInFileNames": true,
},
}

0 comments on commit d24c990

Please sign in to comment.