-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbin.js
executable file
·42 lines (31 loc) · 1.03 KB
/
bin.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/env node
const path = require("path");
const argv = require("yargs")
.usage(`Converts SAZ file (from Fiddler) to HAR file.
Usage: $0 [options] input.saz [output.har]`)
.option("no-validate", {
type: "boolean",
description: "Validate the output HAR file (default: true)"
})
.example("$0 foo.saz bar.har --no-validate")
.argv;
const saz2har = require("./");
const sourceFile = argv.source || argv.s || argv._[0];
const destinationFile = argv.destination || argv.d || argv._[1];
const options = {
write: true,
validate: argv.validate
};
const callback = (err, data) => {
if (err) {
console.error("Error: ", err);
return;
}
const { source, destination } = data;
console.log(`Successful conversion from ${source} to ${destination}`);
};
if (sourceFile && destinationFile) {
saz2har.convert(path.resolve(sourceFile), path.resolve(destinationFile), options, callback);
} else if (sourceFile) {
saz2har.convert(path.resolve(sourceFile), options, callback);
}