Completed
Push — master ( 03001f...fdb517 )
by Elbert
01:08
created

src/drivers/npm/index.js   A

Complexity

Total Complexity 7
Complexity/F 1.75

Size

Lines of Code 32
Function Count 4

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
c 1
b 0
f 0
nc 2
dl 0
loc 32
rs 10
wmc 7
mnd 2
bc 7
fnc 4
bpm 1.75
cpm 1.75
noi 0

1 Function

Rating   Name   Duplication   Size   Complexity  
A exports.run 0 13 1
1
'use strict';
2
3
const
4
	path      = require('path'),
5
	spawn     = require('child_process').spawn,
6
	phantomjs = require('phantomjs-prebuilt');
7
8
exports.run = function(args, callback) {
9
	args.unshift.apply(args, [path.join(__dirname, 'driver.js'), '--web-security=false', '--load-images=false', '--ignore-ssl-errors=yes', '--ssl-protocol=any']);
10
11
	var driver = phantomjs.exec.apply(this, args);
12
13
	driver.stdout.on('data', (data) => {
14
		callback(`${data}`, null);
15
	});
16
17
	driver.stderr.on('data', (data) => {
18
		callback(null, `${data}`);
19
	});
20
}
21
22
if ( !module.parent ) {
23
	exports.run(process.argv.slice(2), function(stdout, stderr) {
24
		if ( stdout ) {
25
			process.stdout.write(stdout);
26
		}
27
28
		if ( stderr ) {
29
			process.stderr.write(stderr);
30
		}
31
	});
32
}
33