Don't fail on missing ~/.docker dir

This is a follow-up to 8828a2343e / #39
This commit is contained in:
Daniel Rudolf 2024-08-07 11:34:44 +02:00
parent 4934294ad0
commit 913e9b2934
No known key found for this signature in database
GPG key ID: A061F02CD8DE4538

View file

@ -15,7 +15,8 @@ import { Inputs } from "./generated/inputs-outputs";
let podmanPath: string | undefined; let podmanPath: string | undefined;
let registry: string; let registry: string;
const dockerConfigPath = path.join(os.homedir(), ".docker", "config.json"); const dockerConfigDir = path.join(os.homedir(), ".docker");
const dockerConfigPath = path.join(dockerConfigDir, "config.json");
async function getPodmanPath(): Promise<string> { async function getPodmanPath(): Promise<string> {
if (podmanPath == null) { if (podmanPath == null) {
@ -91,7 +92,8 @@ async function run(): Promise<void> {
dockerConfig.auths[registry] = generatedAuth; dockerConfig.auths[registry] = generatedAuth;
await fs.writeFile(dockerConfigPath, JSON.stringify(dockerConfig, undefined, 8), "utf-8"); await fs.mkdir(dockerConfigDir, { recursive: true })
.then(() => fs.writeFile(dockerConfigPath, JSON.stringify(dockerConfig, undefined, 8), "utf-8"));
} }
async function registryLogout(): Promise<void> { async function registryLogout(): Promise<void> {