Skip to content

Commit a64653c

Browse files
committed
style: use let for dynamic values only
1 parent 75482ee commit a64653c

File tree

9 files changed

+79
-80
lines changed

9 files changed

+79
-80
lines changed

src/goods.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export * as os from 'node:os'
2929

3030
export const argv = minimist(process.argv.slice(2))
3131
export function updateArgv(args: string[]) {
32-
for (var k in argv) delete argv[k]
32+
for (const k in argv) delete argv[k]
3333
Object.assign(argv, minimist(args))
3434
}
3535

test/cli.test.js

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,14 @@ describe('cli', () => {
4848
})
4949

5050
test('prints help', async () => {
51-
let p = $`node build/cli.js -h`
51+
const p = $`node build/cli.js -h`
5252
p.stdin.end()
53-
let help = await p
53+
const help = await p
5454
assert.match(help.stdout, /zx/)
5555
})
5656

5757
test('zx prints usage if no param passed', async () => {
58-
let p = $`node build/cli.js`
58+
const p = $`node build/cli.js`
5959
p.stdin.end()
6060
try {
6161
await p
@@ -67,70 +67,70 @@ describe('cli', () => {
6767
})
6868

6969
test('starts repl with --repl', async () => {
70-
let p = $`node build/cli.js --repl`
70+
const p = $`node build/cli.js --repl`
7171
p.stdin.write('await $`echo f"o"o`\n')
7272
p.stdin.write('"b"+"ar"\n')
7373
p.stdin.end()
74-
let out = await p
74+
const out = await p
7575
assert.match(out.stdout, /foo/)
7676
assert.match(out.stdout, /bar/)
7777
})
7878

7979
test('starts repl with verbosity off', async () => {
80-
let p = $`node build/cli.js --repl`
80+
const p = $`node build/cli.js --repl`
8181
p.stdin.write('"verbose" + " is " + $.verbose\n')
8282
p.stdin.end()
83-
let out = await p
83+
const out = await p
8484
assert.match(out.stdout, /verbose is false/)
8585
})
8686

8787
test('supports `--quiet` flag', async () => {
88-
let p = await $`node build/cli.js --quiet test/fixtures/markdown.md`
88+
const p = await $`node build/cli.js --quiet test/fixtures/markdown.md`
8989
assert.ok(!p.stderr.includes('ignore'), 'ignore was printed')
9090
assert.ok(!p.stderr.includes('hello'), 'no hello')
9191
assert.ok(p.stdout.includes('world'), 'no world')
9292
})
9393

9494
test('supports `--shell` flag ', async () => {
95-
let shell = $.shell
96-
let p =
95+
const shell = $.shell
96+
const p =
9797
await $`node build/cli.js --verbose --shell=${shell} <<< '$\`echo \${$.shell}\`'`
9898
assert.ok(p.stderr.includes(shell))
9999
})
100100

101101
test('supports `--prefix` flag ', async () => {
102-
let prefix = 'set -e;'
103-
let p =
102+
const prefix = 'set -e;'
103+
const p =
104104
await $`node build/cli.js --verbose --prefix=${prefix} <<< '$\`echo \${$.prefix}\`'`
105105
assert.ok(p.stderr.includes(prefix))
106106
})
107107

108108
test('supports `--postfix` flag ', async () => {
109-
let postfix = '; exit 0'
110-
let p =
109+
const postfix = '; exit 0'
110+
const p =
111111
await $`node build/cli.js --verbose --postfix=${postfix} <<< '$\`echo \${$.postfix}\`'`
112112
assert.ok(p.stderr.includes(postfix))
113113
})
114114

115115
test('supports `--cwd` option ', async () => {
116-
let cwd = path.resolve(fileURLToPath(import.meta.url), '../../temp')
116+
const cwd = path.resolve(fileURLToPath(import.meta.url), '../../temp')
117117
fs.mkdirSync(cwd, { recursive: true })
118-
let p =
118+
const p =
119119
await $`node build/cli.js --verbose --cwd=${cwd} <<< '$\`echo \${$.cwd}\`'`
120120
assert.ok(p.stderr.endsWith(cwd + '\n'))
121121
})
122122

123123
test('scripts from https', async () => {
124124
const server = $`cat ${path.resolve('test/fixtures/echo.http')} | nc -l 8080`
125-
let out =
125+
const out =
126126
await $`node build/cli.js --verbose http://127.0.0.1:8080/echo.mjs`
127127
assert.match(out.stderr, /test/)
128128
await server.kill()
129129
})
130130

131131
test('scripts from https not ok', async () => {
132132
const server = $`echo $'HTTP/1.1 500\n\n' | nc -l 8081`
133-
let out = await $`node build/cli.js http://127.0.0.1:8081`.nothrow()
133+
const out = await $`node build/cli.js http://127.0.0.1:8081`.nothrow()
134134
assert.match(out.stderr, /Error: Can't get/)
135135
await server.kill()
136136
})
@@ -145,7 +145,7 @@ describe('cli', () => {
145145
})
146146

147147
test('require() is working from stdin', async () => {
148-
let out =
148+
const out =
149149
await $`node build/cli.js <<< 'console.log(require("./package.json").name)'`
150150
assert.match(out.stdout, /zx/)
151151
})
@@ -167,14 +167,14 @@ describe('cli', () => {
167167
})
168168

169169
test('markdown scripts are working for CRLF', async () => {
170-
let p = await $`node build/cli.js test/fixtures/markdown-crlf.md`
170+
const p = await $`node build/cli.js test/fixtures/markdown-crlf.md`
171171
assert.ok(p.stdout.includes('Hello, world!'))
172172
})
173173

174174
test('exceptions are caught', async () => {
175-
let out1 = await $`node build/cli.js <<<${'await $`wtf`'}`.nothrow()
175+
const out1 = await $`node build/cli.js <<<${'await $`wtf`'}`.nothrow()
176+
const out2 = await $`node build/cli.js <<<'throw 42'`.nothrow()
176177
assert.match(out1.stderr, /Error:/)
177-
let out2 = await $`node build/cli.js <<<'throw 42'`.nothrow()
178178
assert.match(out2.stderr, /42/)
179179
})
180180

@@ -184,7 +184,7 @@ describe('cli', () => {
184184
})
185185

186186
test('eval works with stdin', async () => {
187-
let p = $`(printf foo; sleep 0.1; printf bar) | node build/cli.js --eval 'echo(await stdin())'`
187+
const p = $`(printf foo; sleep 0.1; printf bar) | node build/cli.js --eval 'echo(await stdin())'`
188188
assert.equal((await p).stdout, 'foobar\n')
189189
})
190190

@@ -231,7 +231,7 @@ describe('cli', () => {
231231
})
232232

233233
test('exit code can be set', async () => {
234-
let p = await $`node build/cli.js test/fixtures/exit-code.mjs`.nothrow()
234+
const p = await $`node build/cli.js test/fixtures/exit-code.mjs`.nothrow()
235235
assert.equal(p.exitCode, 42)
236236
})
237237

0 commit comments

Comments
 (0)