[codex] Enforce canonical Node namespace imports (#3238)

Co-authored-by: codex <[email protected]>
This commit is contained in:
Julius Marmingeandcodex authored and GitHub committed 2026-06-20 01:06:37 -07:00
1 parent db27502aff
commit 2fa37ec183
71 files changed
+1205 -952

No files matched your search

+15 -15
View File
@@ -1,6 +1,6 @@
// @effect-diagnostics nodeBuiltinImport:off
import fs from "node:fs";
import path from "node:path";
import * as NodeFS from "node:fs";
import * as NodePath from "node:path";
export interface RotatingFileSinkOptions {
readonly filePath: string;
@@ -29,7 +29,7 @@ export class RotatingFileSink {
this.maxFiles = options.maxFiles;
this.throwOnError = options.throwOnError ?? false;
fs.mkdirSync(path.dirname(this.filePath), { recursive: true });
NodeFS.mkdirSync(NodePath.dirname(this.filePath), { recursive: true });
this.pruneOverflowBackups();
this.currentSize = this.readCurrentSize();
}
@@ -43,7 +43,7 @@ export class RotatingFileSink {
this.rotate();
}
fs.appendFileSync(this.filePath, buffer);
NodeFS.appendFileSync(this.filePath, buffer);
this.currentSize += buffer.length;
if (this.currentSize > this.maxBytes) {
@@ -60,20 +60,20 @@ export class RotatingFileSink {
private rotate(): void {
try {
const oldest = this.withSuffix(this.maxFiles);
if (fs.existsSync(oldest)) {
fs.rmSync(oldest, { force: true });
if (NodeFS.existsSync(oldest)) {
NodeFS.rmSync(oldest, { force: true });
}
for (let index = this.maxFiles - 1; index >= 1; index -= 1) {
const source = this.withSuffix(index);
const target = this.withSuffix(index + 1);
if (fs.existsSync(source)) {
fs.renameSync(source, target);
if (NodeFS.existsSync(source)) {
NodeFS.renameSync(source, target);
}
}
if (fs.existsSync(this.filePath)) {
fs.renameSync(this.filePath, this.withSuffix(1));
if (NodeFS.existsSync(this.filePath)) {
NodeFS.renameSync(this.filePath, this.withSuffix(1));
}
this.currentSize = 0;
@@ -87,13 +87,13 @@ export class RotatingFileSink {
private pruneOverflowBackups(): void {
try {
const dir = path.dirname(this.filePath);
const baseName = path.basename(this.filePath);
for (const entry of fs.readdirSync(dir)) {
const dir = NodePath.dirname(this.filePath);
const baseName = NodePath.basename(this.filePath);
for (const entry of NodeFS.readdirSync(dir)) {
if (!entry.startsWith(`${baseName}.`)) continue;
const suffix = Number(entry.slice(baseName.length + 1));
if (!Number.isInteger(suffix) || suffix <= this.maxFiles) continue;
fs.rmSync(path.join(dir, entry), { force: true });
NodeFS.rmSync(NodePath.join(dir, entry), { force: true });
}
} catch {
if (this.throwOnError) {
@@ -104,7 +104,7 @@ export class RotatingFileSink {
private readCurrentSize(): number {
try {
return fs.statSync(this.filePath).size;
return NodeFS.statSync(this.filePath).size;
} catch {
return 0;
}
+8 -8
View File
@@ -1,8 +1,8 @@
// @effect-diagnostics nodeBuiltinImport:off
import * as NodeOS from "node:os";
import * as NodePath from "node:path";
import { execFileSync } from "node:child_process";
import { accessSync, constants as fileSystemConstants, statSync } from "node:fs";
import * as NodeChildProcess from "node:child_process";
import * as NodeFS from "node:fs";
import * as Data from "effect/Data";
import * as Effect from "effect/Effect";
import * as FileSystem from "effect/FileSystem";
@@ -26,7 +26,7 @@ type ExecFileSyncLike = (
function canExecuteFile(filePath: string): boolean {
try {
accessSync(filePath, fileSystemConstants.X_OK);
NodeFS.accessSync(filePath, NodeFS.constants.X_OK);
return true;
} catch {
return false;
@@ -108,7 +108,7 @@ function resolveSpawnExecutableWithNode(
);
const isExecutable = (candidate: string) => {
try {
if (!statSync(candidate).isFile()) return false;
if (!NodeFS.statSync(candidate).isFile()) return false;
if (platform === "win32") {
return windowsPathExtensions.includes(path.extname(candidate).toUpperCase());
}
@@ -192,13 +192,13 @@ export function extractPathFromShellOutput(output: string): string | null {
export function readPathFromLoginShell(
shell: string,
execFile: ExecFileSyncLike = execFileSync,
execFile: ExecFileSyncLike = NodeChildProcess.execFileSync,
): string | undefined {
return readEnvironmentFromLoginShell(shell, ["PATH"], execFile).PATH;
}
export function readPathFromLaunchctl(
execFile: ExecFileSyncLike = execFileSync,
execFile: ExecFileSyncLike = NodeChildProcess.execFileSync,
): string | undefined {
try {
return trimNonEmpty(
@@ -305,7 +305,7 @@ export type ShellEnvironmentReader = (
export const readEnvironmentFromLoginShell: ShellEnvironmentReader = (
shell,
names,
execFile = execFileSync,
execFile = NodeChildProcess.execFileSync,
) => {
if (names.length === 0) {
return {};
@@ -371,7 +371,7 @@ export function readEnvironmentFromWindowsShell(
const execFile: ExecFileSyncLike =
typeof optionsOrExecFile === "function"
? optionsOrExecFile
: (maybeExecFile ?? (execFileSync as ExecFileSyncLike));
: (maybeExecFile ?? (NodeChildProcess.execFileSync as ExecFileSyncLike));
const command = buildWindowsEnvironmentCaptureCommand(names);
const args = [
"-NoLogo",