Skip to content

Commit 4dd8ab4

Browse files
authored
Simplify inputs.ts (#827)
Do not pass around inputs. Its okay to freely work with core.getInput in this file
1 parent 7fdbe7c commit 4dd8ab4

4 files changed

Lines changed: 80 additions & 122 deletions

File tree

__tests__/utils/inputs.test.ts

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jest.unstable_mockModule("@actions/core", () => ({
3636

3737
const { CacheLocalSource, loadInputs } = await import("../../src/utils/inputs");
3838

39-
function createTempProject(files: Record<string, string>): string {
39+
function createTempProject(files: Record<string, string> = {}): string {
4040
const dir = fs.mkdtempSync(path.join(os.tmpdir(), "setup-uv-inputs-test-"));
4141
tempDirs.push(dir);
4242

@@ -60,11 +60,8 @@ function resetEnvironment(): void {
6060
}
6161

6262
function restoreEnvironment(): void {
63-
while (tempDirs.length > 0) {
64-
const dir = tempDirs.pop();
65-
if (dir !== undefined) {
66-
fs.rmSync(dir, { force: true, recursive: true });
67-
}
63+
for (const dir of tempDirs.splice(0)) {
64+
fs.rmSync(dir, { force: true, recursive: true });
6865
}
6966

7067
process.env.HOME = ORIGINAL_HOME;
@@ -74,13 +71,8 @@ function restoreEnvironment(): void {
7471
process.env.UV_PYTHON_INSTALL_DIR = ORIGINAL_UV_PYTHON_INSTALL_DIR;
7572
}
7673

77-
beforeEach(() => {
78-
resetEnvironment();
79-
});
80-
81-
afterEach(() => {
82-
restoreEnvironment();
83-
});
74+
beforeEach(resetEnvironment);
75+
afterEach(restoreEnvironment);
8476

8577
describe("loadInputs", () => {
8678
it("loads defaults for a github-hosted runner", () => {
@@ -125,7 +117,7 @@ cache-dir = "/tmp/pyproject-toml-defined-cache-path"
125117
});
126118

127119
it("uses UV_CACHE_DIR from the environment", () => {
128-
mockInputs["working-directory"] = createTempProject({});
120+
mockInputs["working-directory"] = createTempProject();
129121
process.env.UV_CACHE_DIR = "/env/cache-dir";
130122

131123
const inputs = loadInputs();

dist/save-cache/index.cjs

Lines changed: 24 additions & 31 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/setup/index.cjs

Lines changed: 24 additions & 31 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)