Showing the changes to packages/shared/src (2 of 71 files). Show all
Unified · Split
| @@ -1,6 +1,6 @@ | ||
| 1 | 1 | // @effect-diagnostics nodeBuiltinImport:off |
| 2 | −import fs from "node:fs"; | |
| 3 | −import path from "node:path"; | |
| 2 | +import * as NodeFS from "node:fs"; | |
| 3 | +import * as NodePath from "node:path"; | |
| 4 | 4 | |
| 5 | 5 | export interface RotatingFileSinkOptions { |
| 6 | 6 | readonly filePath: string; |
| @@ -29,7 +29,7 @@ export class RotatingFileSink { · 22 unmodified lines | ||
| 29 | 29 | this.maxFiles = options.maxFiles; |
| 30 | 30 | this.throwOnError = options.throwOnError ?? false; |
| 31 | 31 | |
| 32 | − fs.mkdirSync(path.dirname(this.filePath), { recursive: true }); | |
| 32 | + NodeFS.mkdirSync(NodePath.dirname(this.filePath), { recursive: true }); | |
| 33 | 33 | this.pruneOverflowBackups(); |
| 34 | 34 | this.currentSize = this.readCurrentSize(); |
| 35 | 35 | } |
| @@ -43,7 +43,7 @@ export class RotatingFileSink { · 7 unmodified lines | ||
| 43 | 43 | this.rotate(); |
| 44 | 44 | } |
| 45 | 45 | |
| 46 | − fs.appendFileSync(this.filePath, buffer); | |
| 46 | + NodeFS.appendFileSync(this.filePath, buffer); | |
| 47 | 47 | this.currentSize += buffer.length; |
| 48 | 48 | |
| 49 | 49 | if (this.currentSize > this.maxBytes) { |
| @@ -60,20 +60,20 @@ export class RotatingFileSink { · 10 unmodified lines | ||
| 60 | 60 | private rotate(): void { |
| 61 | 61 | try { |
| 62 | 62 | const oldest = this.withSuffix(this.maxFiles); |
| 63 | − if (fs.existsSync(oldest)) { | |
| 64 | − fs.rmSync(oldest, { force: true }); | |
| 63 | + if (NodeFS.existsSync(oldest)) { | |
| 64 | + NodeFS.rmSync(oldest, { force: true }); | |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | for (let index = this.maxFiles - 1; index >= 1; index -= 1) { |
| 68 | 68 | const source = this.withSuffix(index); |
| 69 | 69 | const target = this.withSuffix(index + 1); |
| 70 | − if (fs.existsSync(source)) { | |
| 71 | − fs.renameSync(source, target); | |
| 70 | + if (NodeFS.existsSync(source)) { | |
| 71 | + NodeFS.renameSync(source, target); | |
| 72 | 72 | } |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | − if (fs.existsSync(this.filePath)) { | |
| 76 | − fs.renameSync(this.filePath, this.withSuffix(1)); | |
| 75 | + if (NodeFS.existsSync(this.filePath)) { | |
| 76 | + NodeFS.renameSync(this.filePath, this.withSuffix(1)); | |
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | this.currentSize = 0; |
| @@ -87,13 +87,13 @@ export class RotatingFileSink { · 7 unmodified lines | ||
| 87 | 87 | |
| 88 | 88 | private pruneOverflowBackups(): void { |
| 89 | 89 | try { |
| 90 | − const dir = path.dirname(this.filePath); | |
| 91 | − const baseName = path.basename(this.filePath); | |
| 92 | − for (const entry of fs.readdirSync(dir)) { | |
| 90 | + const dir = NodePath.dirname(this.filePath); | |
| 91 | + const baseName = NodePath.basename(this.filePath); | |
| 92 | + for (const entry of NodeFS.readdirSync(dir)) { | |
| 93 | 93 | if (!entry.startsWith(`${baseName}.`)) continue; |
| 94 | 94 | const suffix = Number(entry.slice(baseName.length + 1)); |
| 95 | 95 | if (!Number.isInteger(suffix) || suffix <= this.maxFiles) continue; |
| 96 | − fs.rmSync(path.join(dir, entry), { force: true }); | |
| 96 | + NodeFS.rmSync(NodePath.join(dir, entry), { force: true }); | |
| 97 | 97 | } |
| 98 | 98 | } catch { |
| 99 | 99 | if (this.throwOnError) { |
| @@ -104,7 +104,7 @@ export class RotatingFileSink { · 4 unmodified lines | ||
| 104 | 104 | |
| 105 | 105 | private readCurrentSize(): number { |
| 106 | 106 | try { |
| 107 | − return fs.statSync(this.filePath).size; | |
| 107 | + return NodeFS.statSync(this.filePath).size; | |
| 108 | 108 | } catch { |
| 109 | 109 | return 0; |
| 110 | 110 | } |
| @@ -1,8 +1,8 @@ | ||
| 1 | 1 | // @effect-diagnostics nodeBuiltinImport:off |
| 2 | 2 | import * as NodeOS from "node:os"; |
| 3 | 3 | import * as NodePath from "node:path"; |
| 4 | −import { execFileSync } from "node:child_process"; | |
| 5 | −import { accessSync, constants as fileSystemConstants, statSync } from "node:fs"; | |
| 4 | +import * as NodeChildProcess from "node:child_process"; | |
| 5 | +import * as NodeFS from "node:fs"; | |
| 6 | 6 | import * as Data from "effect/Data"; |
| 7 | 7 | import * as Effect from "effect/Effect"; |
| 8 | 8 | import * as FileSystem from "effect/FileSystem"; |
| @@ -26,7 +26,7 @@ type ExecFileSyncLike = ( · 17 unmodified lines | ||
| 26 | 26 | |
| 27 | 27 | function canExecuteFile(filePath: string): boolean { |
| 28 | 28 | try { |
| 29 | − accessSync(filePath, fileSystemConstants.X_OK); | |
| 29 | + NodeFS.accessSync(filePath, NodeFS.constants.X_OK); | |
| 30 | 30 | return true; |
| 31 | 31 | } catch { |
| 32 | 32 | return false; |
| @@ -108,7 +108,7 @@ function resolveSpawnExecutableWithNode( · 75 unmodified lines | ||
| 108 | 108 | ); |
| 109 | 109 | const isExecutable = (candidate: string) => { |
| 110 | 110 | try { |
| 111 | − if (!statSync(candidate).isFile()) return false; | |
| 111 | + if (!NodeFS.statSync(candidate).isFile()) return false; | |
| 112 | 112 | if (platform === "win32") { |
| 113 | 113 | return windowsPathExtensions.includes(path.extname(candidate).toUpperCase()); |
| 114 | 114 | } |
| @@ -192,13 +192,13 @@ export function extractPathFromShellOutput(output: string): string | null { · 77 unmodified lines | ||
| 192 | 192 | |
| 193 | 193 | export function readPathFromLoginShell( |
| 194 | 194 | shell: string, |
| 195 | − execFile: ExecFileSyncLike = execFileSync, | |
| 195 | + execFile: ExecFileSyncLike = NodeChildProcess.execFileSync, | |
| 196 | 196 | ): string | undefined { |
| 197 | 197 | return readEnvironmentFromLoginShell(shell, ["PATH"], execFile).PATH; |
| 198 | 198 | } |
| 199 | 199 | |
| 200 | 200 | export function readPathFromLaunchctl( |
| 201 | − execFile: ExecFileSyncLike = execFileSync, | |
| 201 | + execFile: ExecFileSyncLike = NodeChildProcess.execFileSync, | |
| 202 | 202 | ): string | undefined { |
| 203 | 203 | try { |
| 204 | 204 | return trimNonEmpty( |
| @@ -305,7 +305,7 @@ export type ShellEnvironmentReader = ( · 100 unmodified lines | ||
| 305 | 305 | export const readEnvironmentFromLoginShell: ShellEnvironmentReader = ( |
| 306 | 306 | shell, |
| 307 | 307 | names, |
| 308 | − execFile = execFileSync, | |
| 308 | + execFile = NodeChildProcess.execFileSync, | |
| 309 | 309 | ) => { |
| 310 | 310 | if (names.length === 0) { |
| 311 | 311 | return {}; |
| @@ -371,7 +371,7 @@ export function readEnvironmentFromWindowsShell( · 59 unmodified lines | ||
| 371 | 371 | const execFile: ExecFileSyncLike = |
| 372 | 372 | typeof optionsOrExecFile === "function" |
| 373 | 373 | ? optionsOrExecFile |
| 374 | − : (maybeExecFile ?? (execFileSync as ExecFileSyncLike)); | |
| 374 | + : (maybeExecFile ?? (NodeChildProcess.execFileSync as ExecFileSyncLike)); | |
| 375 | 375 | const command = buildWindowsEnvironmentCaptureCommand(names); |
| 376 | 376 | const args = [ |
| 377 | 377 | "-NoLogo", |