Skip to content

Commit f600cca

Browse files
committed
chore: minor code imprs
1 parent ec82c23 commit f600cca

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/cli.ts

+3-5
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ import { startRepl } from './repl.ts'
3434
import { randomId } from './util.ts'
3535
import { transformMarkdown } from './md.ts'
3636
import { createRequire, type minimist } from './vendor.ts'
37-
import { unlinkSync } from 'fs'
3837

3938
const EXT = '.mjs'
4039
const EXT_RE = /^\.[mc]?[jt]sx?$/
@@ -82,6 +81,7 @@ export function printUsage() {
8281

8382
// prettier-ignore
8483
export const argv: minimist.ParsedArgs = parseArgv(process.argv.slice(2), {
84+
default: { ['prefer-local']: false },
8585
// exclude 'prefer-local' to let minimist infer the type
8686
string: ['shell', 'prefix', 'postfix', 'eval', 'cwd', 'ext', 'registry', 'env'],
8787
boolean: ['version', 'help', 'quiet', 'verbose', 'install', 'repl', 'experimental'],
@@ -130,17 +130,15 @@ async function runScript(
130130
): Promise<void> {
131131
let nm = ''
132132
const rmTemp = () => {
133-
const rmOpts = { force: true, recursive: true }
134-
fs.rmSync(tempPath, rmOpts)
135-
nm && fs.rmSync(nm, rmOpts)
133+
fs.rmSync(tempPath, { force: true, recursive: true })
134+
nm && fs.rmSync(nm, { force: true, recursive: true })
136135
}
137136
try {
138137
if (tempPath) {
139138
scriptPath = tempPath
140139
await fs.writeFile(tempPath, script)
141140
}
142141
const cwd = path.dirname(scriptPath)
143-
144142
if (typeof argv.preferLocal === 'string') {
145143
nm = linkNodeModules(cwd, argv.preferLocal)
146144
}

test/export.test.js

+2
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ describe('cli', () => {
6868
assert.equal(typeof cli.argv.help, 'boolean', 'cli.argv.help')
6969
assert.equal(typeof cli.argv.i, 'boolean', 'cli.argv.i')
7070
assert.equal(typeof cli.argv.install, 'boolean', 'cli.argv.install')
71+
assert.equal(typeof cli.argv.l, 'boolean', 'cli.argv.l')
72+
assert.equal(typeof cli.argv.preferLocal, 'boolean', 'cli.argv.preferLocal')
7173
assert.equal(typeof cli.argv.quiet, 'boolean', 'cli.argv.quiet')
7274
assert.equal(typeof cli.argv.repl, 'boolean', 'cli.argv.repl')
7375
assert.equal(typeof cli.argv.v, 'boolean', 'cli.argv.v')

0 commit comments

Comments
 (0)