Warn when the workdir is empty (#322)

Closes: #306
This commit is contained in:
Kevin Stillhammer
2025-03-16 22:15:17 +01:00
committed by GitHub
parent 0e855c90d0
commit a05a582c56
6 changed files with 57 additions and 2 deletions

View File

@ -16,6 +16,7 @@ import {
import {
cacheLocalPath,
checkSum,
ignoreEmptyWorkdir,
enableCache,
githubToken,
pyProjectFile,
@ -30,6 +31,7 @@ import fs from "node:fs";
import { getUvVersionFromConfigFile } from "./utils/pyproject";
async function run(): Promise<void> {
detectEmptyWorkdir();
const platform = await getPlatform();
const arch = getArch();
@ -61,6 +63,20 @@ async function run(): Promise<void> {
}
}
function detectEmptyWorkdir(): void {
if (fs.readdirSync(".").length === 0) {
if (ignoreEmptyWorkdir) {
core.info(
"Empty workdir detected. Ignoring because ignore-empty-workdir is enabled",
);
} else {
core.warning(
"Empty workdir detected. This may cause unexpected behavior. You can enable ignore-empty-workdir to mute this warning.",
);
}
}
}
async function setupUv(
platform: Platform,
arch: Architecture,