Skip to content

Commit 2271e97

Browse files
committed
fix(cli): fix updateArgv block
1 parent 75a9549 commit 2271e97

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/cli.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -151,13 +151,13 @@ async function runScript(
151151

152152
async function readScript() {
153153
const [firstArg] = argv._
154-
updateArgv(argv._.slice(firstArg === undefined ? 0 : 1))
155-
156154
let script = ''
157155
let scriptPath = ''
158156
let tempPath = ''
157+
let argSlice = 1
159158

160159
if (argv.eval) {
160+
argSlice = 0
161161
script = argv.eval
162162
tempPath = getFilepath($.cwd, 'zx', argv.ext)
163163
} else if (!firstArg || firstArg === '-') {
@@ -169,8 +169,8 @@ async function readScript() {
169169
throw new Error('No script provided')
170170
}
171171
} else if (/^https?:/.test(firstArg)) {
172-
script = await readScriptFromHttp(firstArg)
173172
const { name, ext = argv.ext } = path.parse(new URL(firstArg).pathname)
173+
script = await readScriptFromHttp(firstArg)
174174
tempPath = getFilepath($.cwd, name, ext)
175175
} else {
176176
script = await fs.readFile(firstArg, 'utf8')
@@ -187,6 +187,7 @@ async function readScript() {
187187
script = transformMarkdown(script)
188188
tempPath = getFilepath(dir, base)
189189
}
190+
if (argSlice) updateArgv(argv._.slice(argSlice))
190191

191192
return { script, scriptPath, tempPath }
192193
}

0 commit comments

Comments
 (0)