Skip to content

Commit 65185fe

Browse files
authored
Dev (#724)
* Only import repl if needed * await node:repl * Do not throw on win which
1 parent 0c97b9f commit 65185fe

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

src/cli.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import {
2626
minimist,
2727
fs,
2828
} from './index.js'
29-
import { startRepl } from './repl.js'
3029
import { randomId } from './util.js'
3130
import { installDeps, parseDeps } from './deps.js'
3231

@@ -77,7 +76,7 @@ await (async function main() {
7776
return
7877
}
7978
if (argv.repl) {
80-
startRepl()
79+
await (await import('./repl.js')).startRepl()
8180
return
8281
}
8382
if (argv.eval) {

src/core.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,12 @@ try {
8484
defaults.quote = quote
8585
} catch (err) {
8686
if (process.platform == 'win32') {
87-
defaults.shell = which.sync('powershell.exe')
88-
defaults.quote = quotePowerShell
87+
try {
88+
defaults.shell = which.sync('powershell.exe')
89+
defaults.quote = quotePowerShell
90+
} catch (err) {
91+
// no powershell?
92+
}
8993
}
9094
}
9195

src/repl.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,13 @@
1414

1515
import os from 'node:os'
1616
import path from 'node:path'
17-
import repl from 'node:repl'
1817
import { inspect } from 'node:util'
1918
import { ProcessOutput, defaults } from './core.js'
2019
import { chalk } from './vendor.js'
2120

22-
export function startRepl() {
21+
export async function startRepl() {
2322
defaults.verbose = false
24-
const r = repl.start({
23+
const r = (await import('node:repl')).start({
2524
prompt: chalk.greenBright.bold('❯ '),
2625
useGlobal: true,
2726
preview: false,

0 commit comments

Comments
 (0)