Skip to content

Commit 1fbac54

Browse files
committed
Fix passing multiple —header flags
Closes #43
1 parent e9b5a7a commit 1fbac54

File tree

5 files changed

+14
-13
lines changed

5 files changed

+14
-13
lines changed

.github/workflows/main.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ jobs:
1212
node-version:
1313
- 18
1414
- 16
15-
- 14
1615
steps:
1716
- uses: actions/checkout@v3
1817
- uses: actions/setup-node@v3

cli.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import process from 'node:process';
33
import meow from 'meow';
44
import captureWebsite from 'capture-website';
5-
import arrify from 'arrify';
65
import splitOnFirst from 'split-on-first';
76
import getStdin from 'get-stdin';
87

@@ -166,6 +165,7 @@ const cli = meow(`
166165
},
167166
header: {
168167
type: 'string',
168+
isMultiple: true,
169169
},
170170
userAgent: {
171171
type: 'string',
@@ -222,11 +222,13 @@ if (options.clip) {
222222
}
223223

224224
options.headers = {};
225-
for (const header of arrify(options.header)) {
225+
for (const header of options.header) {
226226
const [key, value] = header.split(':');
227227
options.headers[key.trim()] = value.trim();
228228
}
229229

230+
delete options.header;
231+
230232
if (options.authentication) {
231233
const [username, password] = splitOnFirst(options.authentication, ':');
232234
options.authentication = {username, password};
@@ -256,7 +258,7 @@ if (options.inset) {
256258

257259
options.isJavaScriptEnabled = options.javascript;
258260

259-
(async () => {
261+
async function main() {
260262
const {
261263
internalPrintFlags,
262264
listDevices,
@@ -288,4 +290,6 @@ options.isJavaScriptEnabled = options.javascript;
288290
} else {
289291
process.stdout.write(await captureWebsite.buffer(input, options));
290292
}
291-
})();
293+
}
294+
295+
await main();

package.json

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,16 @@
4141
"jpg"
4242
],
4343
"dependencies": {
44-
"arrify": "^3.0.0",
45-
"capture-website": "^3.0.0",
44+
"capture-website": "^3.2.0",
4645
"get-stdin": "^9.0.0",
47-
"meow": "^10.1.3",
46+
"meow": "^11.0.0",
4847
"split-on-first": "^3.0.0"
4948
},
5049
"devDependencies": {
51-
"ava": "^4.3.1",
50+
"ava": "^5.2.0",
5251
"create-test-server": "^3.0.1",
53-
"execa": "^6.1.0",
54-
"file-type": "^17.1.6",
55-
"xo": "^0.51.0"
52+
"execa": "^7.1.1",
53+
"file-type": "^18.2.1",
54+
"xo": "^0.54.1"
5655
}
5756
}

test.js.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ Generated by [AVA](https://avajs.dev).
3232
element: '.main-content',
3333
emulateDevice: 'iPhone X',
3434
fullPage: false,
35-
header: 'x-powered-by: capture-website-cli',
3635
headers: {
3736
'x-powered-by': 'capture-website-cli',
3837
},

test.js.snap

-19 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)