-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathMain.coffee
73 lines (60 loc) · 1.66 KB
/
Main.coffee
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
path = require("path")
childProcess = require("child_process")
prompt = require("prompt")
walk = require("walk")
path = require("path")
String::endsWith = (suffix) ->
@indexOf(suffix, @length - suffix.length) isnt -1
onErr = (err) ->
console.log err
1
console.log "Please enter your slack details:"
properties = [
{
message: "Enter your slack domain or company name"
name: "domain"
}
{
name: "email"
validator: /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
warning: "Email is invalid"
}
{
message: "Enter your password (will be hidden)"
name: "password"
hidden: true
}
]
listEmoji = (cb) ->
files = []
# Walker options
walker = walk.walk("./emoji_to_upload",
followLinks: false
)
walker.on "file", (root, stat, next) ->
# Add this file to the list of files
if stat.name.endsWith(".png") or stat.name.endsWith(".gif")
files.push path.resolve(root + "/" + stat.name)
next()
walker.on "end", ->
cb(files)
prompt.start()
prompt.get properties, (err, result) ->
if err
console.log err
return null
listEmoji (files) ->
binPath = "./node_modules/casperjs/bin/casperjs"
childArgs = [
"--ssl-protocol=any"
"--engine=slimerjs",
path.join(__dirname, "Scrape.coffee"),
result.domain,
result.email,
result.password,
files.join("...")
]
#console.log "Running with args: ", childArgs
childProcess.execFile binPath, childArgs, (err, stdout, stderr) ->
console.log "Result:\n#{stdout}\nerror: #{err} #{stderr}"
return null