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
Empty file modified build/cli.js
100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion build/core.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ function formatCmd(cmd) {
}
}
cap();
return out.replaceAll("\n", import_vendor_core.chalk.reset("\n> ")) + "\n";
return out.replace(/\n/g, import_vendor_core.chalk.reset("\n> ")) + "\n";
}

// src/core.ts
Expand Down
16 changes: 9 additions & 7 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,9 @@ function linkNodeModules(cwd: string, external: string): string {
function lstat(p: string) {
try {
return fs.lstatSync(p)
} catch {}
} catch (e) {
if ((e as NodeJS.ErrnoException).code !== 'ENOENT') throw e
}
}

async function readScript() {
Expand Down Expand Up @@ -279,10 +281,10 @@ export function normalizeExt(ext?: string): string | undefined {
// prettier-ignore
function getFilepath(cwd = '.', name = 'zx', _ext?: string): string {
const ext = _ext || argv.ext || EXT
return [
name + ext,
name + '-' + randomId() + ext,
]
.map(f => path.resolve(process.cwd(), cwd, f))
.find(f => !fs.existsSync(f))!
const basePath = path.resolve(process.cwd(), cwd, name)
let filepath = basePath + ext
while (fs.existsSync(filepath)) {
filepath = basePath + '-' + randomId() + ext
}
return filepath
}
9 changes: 7 additions & 2 deletions src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1059,14 +1059,19 @@ export async function kill(
for (const p of await ps.tree({ pid, recursive: true })) {
try {
process.kill(+p.pid, signal)
} catch (e) {}
} catch (e) {
// Ignore if process is already dead
}
}
try {
process.kill(-pid, signal)
} catch (e) {
// Ignore if process group is already dead
try {
process.kill(+pid, signal)
} catch (e) {}
} catch (e) {
// Ignore if process is already dead
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/log.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,5 +218,5 @@ export function formatCmd(cmd: string): string {
}
}
cap()
return out.replaceAll('\n', chalk.reset('\n> ')) + '\n'
return out.replace(/\n/g, chalk.reset('\n> ')) + '\n'
}