Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix] bump caporal to address CVE #143

Merged
merged 1 commit into from
Mar 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 18 additions & 23 deletions bin/har-to-k6.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
const chalk = require('chalk')
const convert = require('../src/convert')
const fs = require('fs')
const io = require('caporal')
const { program: io } = require('@caporal/core')
const pkginfo = require('pkginfo')
const { DEFAULT_CLI_OPTIONS } = require('../src/constants')
const { VError } = require('verror')
Expand All @@ -18,27 +18,22 @@ delete module.exports.version

io.version(version)
.description('Convert LI-HAR to k6 script')
.option(
'-o, --output <output>',
'Output file',
output,
/** @see {normalizeOptions} */
''
)
.option(
'--add-sleep',
'Add automatic sleep() based on startDateTime',
DEFAULT_CLI_OPTIONS.addSleep
)
.option('-o, --output <output>', 'Output file', {
validator: output,
default: '',
})
.option('--add-sleep', 'Add automatic sleep() based on startDateTime', {
default: DEFAULT_CLI_OPTIONS.addSleep,
})
.option(
'-s, --stdout',
'Write to stdout (ignored when running with -o, --output)',
DEFAULT_CLI_OPTIONS.stdout
{ default: DEFAULT_CLI_OPTIONS.stdout }
)
.argument('<archive>', 'LI-HAR archive to convert')
.action(run)

io.parse(process.argv)
io.run(process.argv.slice(2))

function output(value) {
if (fs.existsSync(value) && fs.lstatSync(value).isDirectory()) {
Expand All @@ -58,17 +53,17 @@ function getLogger(log, opt) {
return opt.stdout ? log.warn : log.info
}

async function run(arg, opt, log) {
normalizeOptions(opt)
const logger = getLogger(log, opt)
async function run({ args, options, logger: log }) {
normalizeOptions(options)
const logger = getLogger(log, options)

try {
start(arg.archive, logger)
const json = read(arg.archive)
start(args.archive, logger)
const json = read(args.archive)
const archive = parse(json)
const { main } = await transform(archive, opt)
write(main, opt)
success(opt, logger)
const { main } = await transform(archive, options)
write(main, options)
success(options, logger)
} catch (error) {
inform(error, log)
}
Expand Down
Loading
Loading