Commit 65185fe

Anton Medvedev <anton@medv.io>
2024-02-25 14:40:04
Dev (#724)
* Only import repl if needed * await node:repl * Do not throw on win which
1 parent 0c97b9f
Changed files (3)
src/cli.ts
@@ -26,7 +26,6 @@ import {
   minimist,
   fs,
 } from './index.js'
-import { startRepl } from './repl.js'
 import { randomId } from './util.js'
 import { installDeps, parseDeps } from './deps.js'
 
@@ -77,7 +76,7 @@ await (async function main() {
     return
   }
   if (argv.repl) {
-    startRepl()
+    await (await import('./repl.js')).startRepl()
     return
   }
   if (argv.eval) {
src/core.ts
@@ -84,8 +84,12 @@ try {
   defaults.quote = quote
 } catch (err) {
   if (process.platform == 'win32') {
-    defaults.shell = which.sync('powershell.exe')
-    defaults.quote = quotePowerShell
+    try {
+      defaults.shell = which.sync('powershell.exe')
+      defaults.quote = quotePowerShell
+    } catch (err) {
+      // no powershell?
+    }
   }
 }
 
src/repl.ts
@@ -14,14 +14,13 @@
 
 import os from 'node:os'
 import path from 'node:path'
-import repl from 'node:repl'
 import { inspect } from 'node:util'
 import { ProcessOutput, defaults } from './core.js'
 import { chalk } from './vendor.js'
 
-export function startRepl() {
+export async function startRepl() {
   defaults.verbose = false
-  const r = repl.start({
+  const r = (await import('node:repl')).start({
     prompt: chalk.greenBright.bold('❯ '),
     useGlobal: true,
     preview: false,