Skip to content

Commit f607eaf

Browse files
fix(credentials): mkdir before lock file; satisfy Prettier
acquireCredentialsLock now creates the credentials directory before openSync on the lock path, so first-time setup on a fresh HOME no longer throws ENOENT (fixes subprocess setup/auth tests). Add trailing newline to credentials-write-child.mjs for format:check.
1 parent f3ee6bd commit f607eaf

2 files changed

Lines changed: 4 additions & 1 deletion

File tree

src/lib/credentials.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,9 @@ function withCredentialsLock<T>(credentialsPath: string, fn: () => T): T {
217217

218218
function acquireCredentialsLock(credentialsPath: string): void {
219219
const lockPath = credentialsLockPath(credentialsPath);
220+
// Ensure the credentials directory exists before creating the lock file.
221+
// writeCredentialsAtomic also mkdirs, but only after the lock is held.
222+
mkdirSync(dirname(lockPath), { recursive: true, mode: 0o700 });
220223
const deadline = Date.now() + CREDENTIALS_LOCK_MAX_WAIT_MS;
221224
while (Date.now() < deadline) {
222225
try {

test/helpers/credentials-write-child.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ if (!profile || !credentialsPath || !apiKey) {
99
process.exit(1);
1010
}
1111

12-
writeProfile(profile, { apiKey }, { path: credentialsPath });
12+
writeProfile(profile, { apiKey }, { path: credentialsPath });

0 commit comments

Comments
 (0)