Commit 943f5a78 authored by Aral Balkan's avatar Aral Balkan
Browse files

Now using cross-spawn-async for cross-platform compatibility.

parent 875ec03c
Pipeline #109 skipped
...@@ -32,7 +32,8 @@ module.exports = function electronHAR(url, options, callback) { ...@@ -32,7 +32,8 @@ module.exports = function electronHAR(url, options, callback) {
output: path, output: path,
user: options.user === Object(options.user) ? user: options.user === Object(options.user) ?
options.user.name + ':' + options.user.password : options.user.name + ':' + options.user.password :
options.user, null,
'debug': options['debug'] ? '' : null,
'user-agent': options['user-agent'] ? options['user-agent'] : null, 'user-agent': options['user-agent'] ? options['user-agent'] : null,
'limit-rate': options['limit-rate'] ? options['limit-rate'] : null, 'limit-rate': options['limit-rate'] ? options['limit-rate'] : null,
landscape: options['landscape'] ? options['landscape'] : null landscape: options['landscape'] ? options['landscape'] : null
...@@ -43,18 +44,14 @@ module.exports = function electronHAR(url, options, callback) { ...@@ -43,18 +44,14 @@ module.exports = function electronHAR(url, options, callback) {
var args = [url].concat( var args = [url].concat(
Object Object
.keys(config) .keys(config)
.reduce(function (n, flag) { .reduce(function (argumentsList, flag) {
argv = '' if ( config[flag] !== null) {
if (config[flag] !== undefined && config[flag] !== null ){ argumentsList.push ((flag.length === 1 ? '-' + flag : '--' + flag), config[flag]);
argv = flag.length === 1 ? '-' + flag : '--' + flag;
argv += ' ' + config[flag];
} }
return argv; return argumentsList;
}, []) }, [])
) )
console.log('ARGS: ' + args);
// The callback for the spawned process. // The callback for the spawned process.
var processCallback = function (err, stdout, stderr) { var processCallback = function (err, stdout, stderr) {
if (err) { if (err) {
...@@ -71,7 +68,7 @@ module.exports = function electronHAR(url, options, callback) { ...@@ -71,7 +68,7 @@ module.exports = function electronHAR(url, options, callback) {
} }
try { try {
callback(null, JSON.parse(result)); callback(null, JSON.parse(data));
} catch (e) { } catch (e) {
return callback(e); return callback(e);
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment