Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions build/core.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -1098,9 +1098,7 @@ function syncCwd() {
if ($[CWD] != import_node_process2.default.cwd()) import_node_process2.default.chdir($[CWD]);
}
function cd(dir) {
if (dir instanceof ProcessOutput) {
dir = dir.toString().trim();
}
if (dir instanceof ProcessOutput) return cd(dir.toString().trim());
$.log({ kind: "cd", dir, verbose: !$.quiet && $.verbose });
import_node_process2.default.chdir(dir);
$[CWD] = import_node_process2.default.cwd();
Expand Down
6 changes: 2 additions & 4 deletions src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1026,10 +1026,8 @@ function syncCwd() {
if ($[CWD] != process.cwd()) process.chdir($[CWD])
}

export function cd(dir: string | ProcessOutput) {
if (dir instanceof ProcessOutput) {
dir = dir.toString().trim()
}
export function cd(dir: string | ProcessOutput): void {
if (dir instanceof ProcessOutput) return cd(dir.toString().trim())

$.log({ kind: 'cd', dir, verbose: !$.quiet && $.verbose })
process.chdir(dir)
Comment on lines +1030 to 1033
Copy link
Preview

Copilot AI Aug 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The recursive call creates unnecessary function call overhead. Consider using a local variable assignment instead: const dirStr = dir instanceof ProcessOutput ? dir.toString().trim() : dir; then proceed with the rest of the function using dirStr.

Suggested change
if (dir instanceof ProcessOutput) return cd(dir.toString().trim())
$.log({ kind: 'cd', dir, verbose: !$.quiet && $.verbose })
process.chdir(dir)
const dirStr = dir instanceof ProcessOutput ? dir.toString().trim() : dir;
$.log({ kind: 'cd', dir: dirStr, verbose: !$.quiet && $.verbose })
process.chdir(dirStr)

Copilot uses AI. Check for mistakes.

Expand Down
Loading