forked from ISKU/BOJ-AutoCommit
-
Notifications
You must be signed in to change notification settings - Fork 1
/
casper.js
executable file
·53 lines (41 loc) · 1.17 KB
/
casper.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
43
44
45
46
47
48
49
50
51
52
53
var command = (process.platform === 'win32') ? 'casperjs.cmd' : 'casperjs';
exports.find = function(args, successFind) {
var spawn = require('child_process').spawn(command, args);
var info = new String();
spawn.stdout.on('data', function(data) {
info = JSON.parse(data);
});
spawn.stderr.on('data', function(data) {
console.log(JSON.stringify(data));
});
spawn.on('exit', function(code) {
successFind(info);
});
}
exports.download = function(args, successDownload) {
var spawn = require('child_process').spawn(command, args);
var info = new String();
spawn.stdout.on('data', function(data) {
info = info + String(data);
console.log(String(data));
});
spawn.stderr.on('data', function(data) {
console.log(JSON.stringify(data));
});
spawn.on('exit', function(code) {
successDownload(JSON.parse(info));
});
}
exports.title = function(args, successTitle) {
var spawn = require('child_process').spawn(command, args);
var info = new String();
spawn.stdout.on('data', function(data) {
info = String(data);
});
spawn.stderr.on('data', function(data) {
console.log(JSON.stringify(data));
});
spawn.on('exit', function(code) {
successTitle(info);
});
}