mirror of
https://github.com/affaan-m/ECC.git
synced 2026-08-17 21:15:40 +02:00
* feat(install): add guided Claude plugin setup * fix: support Claude command shims on Windows * feat: support safe Claude plugin scope migration * fix(install): preserve interactive setup terminal * fix(install): auto-migrate setup scope changes * feat(install): add guided multi-harness installer * fix(install): sync Yarn binary metadata * fix(install): handle wizard EOF on Node 18 * ci: allow installer matrix tests to finish * test(install): allow slower PowerShell delegation * fix(install): harden guided provider reconciliation * test(install): harden packaged and local compatibility * chore: prepare guided installer release 2.2.0 * fix(install): report refreshed Codex marketplace state * fix(install): verify managed content provenance * test(install): allow empty Yarn smoke fixture * test(install): invoke Windows package shims safely * fix(install): close cross-platform release gaps * fix(install): require trusted GitHub origins * fix(install): preserve hook profile precedence * refactor(install): centralize trusted GitHub origins * ci: retrigger workflow run after merge of main Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
40 lines
1016 B
JavaScript
40 lines
1016 B
JavaScript
'use strict';
|
|
|
|
const crypto = require('crypto');
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
|
|
function writeFileAtomic(filePath, content, options = {}) {
|
|
const resolvedPath = path.resolve(filePath);
|
|
const parentDir = path.dirname(resolvedPath);
|
|
const tempPath = path.join(
|
|
parentDir,
|
|
`.${path.basename(resolvedPath)}.${process.pid}.${crypto.randomBytes(8).toString('hex')}.tmp`
|
|
);
|
|
const mode = options.mode || 0o600;
|
|
|
|
fs.mkdirSync(parentDir, { recursive: true });
|
|
|
|
let descriptor;
|
|
try {
|
|
descriptor = fs.openSync(tempPath, 'wx', mode);
|
|
fs.writeFileSync(descriptor, content, { encoding: options.encoding || 'utf8' });
|
|
fs.fsyncSync(descriptor);
|
|
fs.closeSync(descriptor);
|
|
descriptor = undefined;
|
|
fs.renameSync(tempPath, resolvedPath);
|
|
} catch (error) {
|
|
if (descriptor !== undefined) {
|
|
fs.closeSync(descriptor);
|
|
}
|
|
fs.rmSync(tempPath, { force: true });
|
|
throw error;
|
|
}
|
|
|
|
return resolvedPath;
|
|
}
|
|
|
|
module.exports = {
|
|
writeFileAtomic,
|
|
};
|