Skip to content

Commit

Permalink
Dev (#724)
Browse files Browse the repository at this point in the history
* Only import repl if needed

* await node:repl

* Do not throw on win which
  • Loading branch information
antonmedv authored Feb 25, 2024
1 parent 0c97b9f commit 65185fe
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
3 changes: 1 addition & 2 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down Expand Up @@ -77,7 +76,7 @@ await (async function main() {
return
}
if (argv.repl) {
startRepl()
await (await import('./repl.js')).startRepl()
return
}
if (argv.eval) {
Expand Down
8 changes: 6 additions & 2 deletions src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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?
}
}
}

Expand Down
5 changes: 2 additions & 3 deletions src/repl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 65185fe

Please sign in to comment.