Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
public async run() {
const { flags } = this.parse(RecordHAR);
const { url, dest, cookiespath, filename, marker } = flags;
const { network, cpuThrottleRate, browserArgs } = this.parsedConfig;
const conditions: IConditions = {
network: network ? network : 'none',
cpu: cpuThrottleRate ? parseInt(cpuThrottleRate as string, 10) : 1,
};
// grab the auth cookies
const cookies = await readJson(resolve(cookiespath));
// record the actual HAR and return the archive file
const harArchive = await recordHARClient(
url,
cookies,
marker,
conditions,
getBrowserArgs(browserArgs)
);
const harPath = join(dest, `${filename}.har`);
writeFileSync(harPath, JSON.stringify(harArchive));
this.log(`HAR recorded and available here: ${harPath}`);
}
}