FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
tinycodecli/index.js at master · darimpulso/tinycodecli · GitHub
darimpulso
/
tinycodecli
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Issues
0
Pull requests
0
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
tinycodecli
/
index.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
572 lines (511 loc) · 18.2 KB
Breadcrumbs
tinycodecli
/
index.js
Copy path
File metadata and controls
572 lines (511 loc) · 18.2 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
#!/usr/bin/env node
var
_
=
require
(
"underscore"
)
,
express
=
require
(
'express'
)
,
app
=
express
(
)
,
server
=
require
(
'http'
)
.
createServer
(
app
)
,
fs
=
require
(
'fs'
)
,
_s
=
require
(
"underscore.string"
)
,
argv
=
require
(
'optimist'
)
.
argv
,
colors
=
require
(
'colors'
)
,
spawn
=
require
(
'child_process'
)
.
spawn
,
Table
=
require
(
'cli-table'
)
,
readline
=
require
(
'readline'
)
,
util
=
require
(
"util"
)
,
request
=
require
(
"request"
)
,
$
=
require
(
"jquery"
)
,
Browser
=
require
(
'zombie'
)
,
sigcount
=
0
_
.
mixin
(
_s
.
exports
(
)
)
;
var
readMe
=
fs
.
readFileSync
(
'./README.md'
,
'utf8'
)
;
console
.
log
(
readMe
)
;
server
.
listen
(
3800
)
var
io
=
require
(
'socket.io'
)
.
listen
(
server
)
;
console
.
log
(
"\n"
)
;
io
.
configure
(
function
(
)
{
io
.
enable
(
'browser client etag'
)
;
io
.
set
(
'log level'
,
0
)
;
io
.
set
(
'transports'
,
[
'websocket'
,
'flashsocket'
,
'htmlfile'
,
'xhr-polling'
,
'jsonp-polling'
]
)
;
}
)
;
io
.
sockets
.
on
(
'connection'
,
function
(
socket
)
{
io
.
sockets
.
emit
(
'this'
,
{
will
:
'be received by everyone'
}
)
;
socket
.
on
(
'message'
,
function
(
from
,
msg
)
{
console
.
log
(
'\n'
)
console
.
log
(
'I received a private message by '
,
from
.
magenta
,
' saying '
,
msg
.
blue
)
;
console
.
log
(
'\n'
)
;
rl
.
prompt
(
)
;
}
)
;
socket
.
on
(
'disconnect'
,
function
(
)
{
io
.
sockets
.
emit
(
'user disconnected'
)
;
}
)
;
}
)
;
rl
=
readline
.
createInterface
(
process
.
stdin
,
process
.
stdout
)
;
var
projectRoot
=
'/Volumes/www'
;
var
vps
=
'daniel.vivid'
;
var
projectPaths
=
fs
.
readdirSync
(
projectRoot
)
;
var
projects
=
_
.
filter
(
projectPaths
,
function
(
path
)
{
if
(
!
_
(
path
)
.
startsWith
(
'.'
)
)
return
path
;
}
)
var
projectTable
=
new
Table
(
{
head
:
[
'Index'
,
'Project'
,
'A'
]
,
colWidths
:
[
20
,
50
,
10
]
}
)
_
.
each
(
projects
,
function
(
project
,
i
)
{
projectTable
.
push
(
[
i
,
project
,
'null'
]
)
}
)
var
directory
=
argv
.
d
?
argv
.
d
:
(
argv
.
p
?
projectRoot
+
'/'
+
argv
.
p
:
__dirname
)
;
var
activeProject
=
argv
.
p
?
argv
.
p
:
'local'
;
rl
.
setPrompt
(
'VIVID WEBCLI '
+
activeProject
+
' > '
)
;
rl
.
prompt
(
{
preserveCursor
:
false
}
)
;
function
gitHub
(
argv
,
callback
)
{
if
(
!
argv
[
1
]
)
return
callback
(
[
'No input file specified'
]
,
null
)
;
var
grep
;
var
args
=
_
.
rest
(
argv
,
2
)
;
console
.
log
(
'Query GIT \n'
.
yellow
)
;
switch
(
argv
[
1
]
)
{
case
"s"
:
grep
=
spawn
(
'git'
,
[
'--git-dir='
+
directory
+
'/.git'
,
'--work-tree='
+
directory
,
'status'
]
)
;
case
"log"
:
grep
=
spawn
(
'git'
,
[
'--git-dir='
+
directory
+
'/.git'
,
'--work-tree='
+
directory
,
'log'
,
(
args
.
length
)
?
args
.
toString
(
)
:
'--all'
]
)
;
break
;
default
:
console
.
log
(
'Unknown command'
)
;
return
rl
.
prompt
(
)
;
}
grep
.
stdout
.
on
(
'data'
,
function
(
data
)
{
console
.
log
(
data
.
toString
(
)
)
;
}
)
grep
.
stderr
.
on
(
'data'
,
function
(
data
)
{
callback
(
data
,
null
)
;
}
)
grep
.
on
(
'close'
,
function
(
)
{
// if(table.length > 0) {
// console.log("\n");
// console.log(table.toString())
// } else {
// console.log('No results .. '.magenta);
// }
// process.nextTick(function(){
// callback(null, 'done');
// })
callback
(
null
,
'done'
)
;
}
)
}
function
finder
(
keyword
,
callback
)
{
if
(
!
keyword
)
return
callback
(
[
'No input file specified'
]
,
null
)
;
var
table
=
new
Table
(
{
head
:
[
'Filename'
,
'Code'
,
'Line'
]
,
colWidths
:
[
70
,
100
,
20
]
}
)
var
grep
=
spawn
(
'git'
,
[
'--git-dir='
+
directory
+
'/.git'
,
'--work-tree='
+
directory
,
'grep'
,
'--line-number'
,
keyword
]
)
;
util
.
puts
(
"\nSearching for Code: "
+
keyword
.
cyan
.
bold
+
" IN "
+
directory
.
cyan
.
bold
+
"\n"
)
;
grep
.
stdout
.
on
(
'data'
,
function
(
data
)
{
var
array
=
data
.
toString
(
)
.
split
(
'\n'
)
;
_
.
map
(
array
,
function
(
obj
)
{
if
(
!
_
(
obj
)
.
isEmpty
(
)
)
{
var
codeAndLine
=
_
(
obj
)
.
strRight
(
':'
)
;
var
code
=
_
(
codeAndLine
)
.
strRight
(
':'
)
;
var
line
=
_
(
codeAndLine
)
.
strLeft
(
':'
)
;
var
fileName
=
_
(
obj
)
.
strLeft
(
':'
)
;
return
table
.
push
(
[
fileName
,
_
.
trim
(
code
)
,
line
]
)
;
}
}
)
}
)
grep
.
stderr
.
on
(
'data'
,
function
(
data
)
{
callback
(
data
,
null
)
;
}
)
grep
.
on
(
'close'
,
function
(
)
{
if
(
table
.
length
>
0
)
{
console
.
log
(
"\n"
)
;
console
.
log
(
table
.
toString
(
)
)
}
else
{
console
.
log
(
'No results .. '
.
magenta
)
;
}
process
.
nextTick
(
function
(
)
{
callback
(
null
,
'done'
)
;
}
)
}
)
}
function
lister
(
keyword
,
callback
)
{
if
(
!
keyword
)
return
callback
(
[
'No input file specified'
]
,
null
)
;
var
foundItems
=
[
]
;
var
table
=
new
Table
(
{
head
:
[
'Index'
,
'File'
]
,
colWidths
:
[
30
,
110
]
}
)
var
regexAll
=
/
[
^
\\
]
*
\.
(
\w
+
)
$
/
;
if
(
!
keyword
.
match
(
regexAll
)
)
{
keyword
=
keyword
+
'*'
;
}
var
find
=
spawn
(
'find'
,
[
directory
,
'-name'
,
keyword
]
)
var
i
=
0
;
util
.
puts
(
"\nSearching for: "
+
keyword
.
cyan
.
bold
+
" IN "
+
directory
.
cyan
.
bold
+
"\n"
)
;
find
.
stdout
.
on
(
'data'
,
function
(
data
)
{
var
array
=
data
.
toString
(
)
.
split
(
'\n'
)
;
_
.
each
(
array
,
function
(
string
)
{
foundItems
.
push
(
string
)
;
if
(
!
_
(
string
)
.
isBlank
(
)
)
{
i
++
;
table
.
push
(
[
i
,
string
]
)
;
}
}
)
}
)
find
.
stderr
.
on
(
'data'
,
function
(
data
)
{
callback
(
data
,
null
)
;
}
)
find
.
on
(
'close'
,
function
(
)
{
if
(
table
.
length
>
0
)
{
console
.
log
(
"\n"
)
;
console
.
log
(
table
.
toString
(
)
)
}
else
{
console
.
log
(
'No results .. '
.
magenta
)
;
}
callback
(
null
,
'done'
)
;
}
)
}
function
remover
(
keyword
,
callback
)
{
var
foundItems
=
[
]
;
var
table
=
new
Table
(
{
head
:
[
'Index'
,
'File'
]
,
colWidths
:
[
30
,
80
]
}
)
var
regexAll
=
/
[
^
\\
]
*
\.
(
\w
+
)
$
/
;
if
(
!
keyword
.
match
(
regexAll
)
)
{
keyword
=
keyword
+
'*'
;
}
var
find
=
spawn
(
'find'
,
[
directory
,
'-name'
,
keyword
]
)
var
i
=
0
;
find
.
stdout
.
on
(
'data'
,
function
(
data
)
{
var
array
=
data
.
toString
(
)
.
split
(
'\n'
)
;
_
.
each
(
array
,
function
(
string
)
{
foundItems
.
push
(
string
)
;
if
(
!
_
(
string
)
.
isBlank
(
)
)
{
i
++
;
table
.
push
(
[
i
,
string
]
)
;
}
}
)
}
)
find
.
stderr
.
on
(
'data'
,
function
(
data
)
{
callback
(
data
,
null
)
;
}
)
find
.
on
(
'close'
,
function
(
)
{
if
(
table
.
length
>
0
)
{
console
.
log
(
"\n"
)
;
console
.
log
(
table
.
toString
(
)
)
}
else
{
console
.
log
(
'No results .. '
.
magenta
)
;
return
callback
(
null
,
'done'
)
;
}
rl
.
question
(
'How do you want to delete? [a(ll)/s(eperated)/c(ancel)] > '
,
function
(
answer
)
{
if
(
answer
.
match
(
'a'
)
)
{
var
fi
=
0
;
var
count
=
_
.
size
(
foundItems
)
;
_
.
each
(
foundItems
,
function
(
foundItem
)
{
fi
++
;
if
(
!
_
(
foundItem
)
.
isBlank
(
)
)
{
fs
.
unlink
(
foundItem
,
function
(
err
)
{
if
(
err
)
{
console
.
error
(
err
)
;
}
else
{
console
.
log
(
'File '
+
foundItem
+
' deleted'
.
green
.
bold
)
;
if
(
fi
>=
count
)
{
callback
(
null
,
'done'
)
;
}
}
}
)
}
}
)
}
else
if
(
answer
.
match
(
's'
)
)
{
rl
.
question
(
'Please enter the indexes seperated by [,] for deletion. [ex: 1,2,3] > '
,
function
(
remAnswer
)
{
if
(
remAnswer
.
match
(
','
)
)
{
var
keys
=
_
.
words
(
remAnswer
,
','
)
;
var
count
=
_
.
size
(
keys
)
;
var
fi
=
0
;
_
.
each
(
keys
,
function
(
key
)
{
fi
++
;
fs
.
unlink
(
foundItems
[
parseInt
(
key
)
-
1
]
,
function
(
err
)
{
fi
++
;
if
(
err
)
{
console
.
log
(
err
.
toSring
(
)
.
red
)
;
}
else
{
console
.
log
(
'File '
+
foundItems
[
parseInt
(
key
)
-
1
]
+
' deleted'
.
green
.
bold
)
;
if
(
fi
>=
count
)
{
callback
(
null
,
'done'
)
;
}
}
}
)
}
)
}
else
{
var
toDelete
=
foundItems
[
parseInt
(
remAnswer
)
-
1
]
;
console
.
log
(
'You are about to delete '
.
bold
+
toDelete
+
''
.
magenta
)
;
rl
.
question
(
'Are you sure [y/n]'
,
function
(
delAnswer
)
{
if
(
delAnswer
.
match
(
'y'
)
)
{
fs
.
unlink
(
toDelete
,
function
(
err
)
{
if
(
err
)
{
console
.
log
(
err
.
toSring
(
)
.
red
)
;
}
else
{
console
.
log
(
'File '
+
toDelete
+
' deleted'
.
green
.
bold
)
;
callback
(
null
,
'done'
)
;
}
}
)
}
else
if
(
delAnswer
.
match
(
'n'
)
)
{
console
.
log
(
'Aborting..'
.
magenta
)
;
callback
(
null
,
'done'
)
;
}
}
)
}
}
)
}
else
if
(
answer
.
match
(
'c'
)
)
{
process
.
nextTick
(
function
(
)
{
callback
(
null
,
'done'
)
;
}
)
}
}
)
}
)
}
rl
.
on
(
'line'
,
function
(
line
)
{
if
(
_
(
line
)
.
isBlank
(
)
)
{
return
rl
.
prompt
(
)
;
}
var
kw
=
_
.
words
(
line
)
;
switch
(
kw
[
0
]
)
{
case
"exit"
:
process
.
exit
(
0
)
;
break
;
case
"ld"
:
console
.
log
(
directory
.
magenta
)
;
return
rl
.
prompt
(
)
;
break
;
case
"del"
:
remover
(
kw
[
1
]
,
function
(
err
,
response
)
{
if
(
err
)
{
console
.
log
(
err
.
toString
(
)
.
red
)
}
console
.
log
(
"\n"
)
;
rl
.
prompt
(
)
;
}
)
break
;
case
"cd"
:
argv
.
d
=
projectRoot
+
'/'
+
kw
[
1
]
;
directory
=
projectRoot
+
'/'
+
kw
[
1
]
;
var
isValidProject
=
_
.
find
(
projects
,
function
(
project
)
{
return
project
===
kw
[
1
]
;
}
)
if
(
!
isValidProject
)
{
console
.
log
(
"\n"
)
;
console
.
log
(
'Project not found'
.
red
)
;
var
regex
=
new
RegExp
(
kw
[
1
]
)
;
var
suggestions
=
_
.
filter
(
projects
,
function
(
project
)
{
return
regex
.
test
(
project
)
;
}
)
console
.
log
(
"\n"
)
;
console
.
log
(
'Maybe you did look for:'
.
underline
)
;
_
.
each
(
suggestions
,
function
(
suggestion
)
{
console
.
log
(
suggestion
.
magenta
)
;
}
)
console
.
log
(
"\n"
)
;
return
rl
.
prompt
(
)
;
}
activeProject
=
kw
[
1
]
;
rl
.
setPrompt
(
'VIVID WEBCLI '
+
activeProject
+
' > '
)
;
console
.
log
(
"\n"
)
;
console
.
log
(
'Project changed to: '
+
_
.
capitalize
(
kw
[
1
]
)
.
green
)
;
console
.
log
(
'Directory changed to '
+
argv
.
d
.
magenta
)
;
console
.
log
(
"\n"
)
;
return
rl
.
prompt
(
)
;
break
;
case
"find"
:
lister
(
kw
[
1
]
,
function
(
err
,
response
)
{
if
(
err
)
{
console
.
log
(
err
.
toString
(
)
.
red
)
}
console
.
log
(
"\n"
)
;
rl
.
prompt
(
)
;
}
)
break
;
case
"g"
:
finder
(
kw
[
1
]
,
function
(
err
,
response
)
{
if
(
err
)
{
console
.
log
(
err
.
toString
(
)
.
red
)
}
console
.
log
(
"\n"
)
;
rl
.
prompt
(
)
;
}
)
break
;
case
"git"
:
gitHub
(
kw
,
function
(
err
,
response
)
{
if
(
err
)
{
console
.
log
(
err
.
toString
(
)
.
red
)
}
console
.
log
(
"\n"
)
;
rl
.
prompt
(
)
;
}
)
break
;
case
"cp"
:
console
.
log
(
projectTable
.
toString
(
)
)
;
console
.
log
(
'\n'
)
;
rl
.
question
(
'Please select a project by its index > '
,
function
(
answer
)
{
if
(
_
(
answer
)
.
isBlank
(
)
)
return
rl
.
prompt
(
)
;
if
(
_
.
isNaN
(
_
(
answer
)
.
toNumber
(
)
)
)
{
console
.
log
(
'Not a Number, aborting .. '
.
red
)
;
return
rl
.
prompt
(
)
;
}
var
index
=
_
(
answer
)
.
toNumber
(
)
;
activeProject
=
projects
[
index
]
;
argv
.
d
=
projectRoot
+
'/'
+
activeProject
;
directory
=
projectRoot
+
'/'
+
activeProject
;
rl
.
setPrompt
(
'VIVID WEBCLI '
+
activeProject
+
' > '
)
;
return
rl
.
prompt
(
)
;
}
)
break
;
case
"send"
:
io
.
sockets
.
emit
(
'com'
,
{
command
:
kw
[
1
]
,
message
:
_
.
rest
(
kw
,
2
)
}
)
;
rl
.
prompt
(
)
;
break
;
case
"lp"
:
var
activeProjects
=
_
.
filter
(
projects
,
function
(
project
)
{
return
!
_
(
project
)
.
startsWith
(
'.'
)
;
}
)
var
pt
=
new
Table
(
{
head
:
[
'Index'
,
'Project Name'
]
,
colWidths
:
[
30
,
80
]
}
)
var
done
=
_
.
map
(
activeProjects
,
function
(
project
,
i
)
{
return
pt
.
push
(
[
i
+
1
,
project
]
)
}
)
console
.
log
(
"\n"
)
;
if
(
done
)
{
console
.
log
(
pt
.
toString
(
)
)
;
}
console
.
log
(
"\n"
)
;
rl
.
prompt
(
)
;
break
;
case
"sh"
:
if
(
!
kw
[
1
]
)
{
console
.
log
(
'Please specify a file (absolute url)!'
.
red
)
;
return
rl
.
prompt
(
)
;
}
fs
.
readFile
(
directory
+
'/'
+
kw
[
1
]
,
"UTF8"
,
function
(
err
,
data
)
{
console
.
log
(
'OUTPUT FILE: '
+
directory
+
'/'
+
kw
[
1
]
)
;
console
.
log
(
data
)
;
console
.
log
(
'\n'
)
;
rl
.
prompt
(
)
;
}
)
;
break
;
case
"dom"
:
var
toServer
=
kw
[
1
]
?
kw
[
1
]
:
'http://'
+
activeProject
+
'.'
+
vps
;
if
(
!
_
(
toServer
)
.
startsWith
(
'http'
)
)
{
toServer
=
'http://'
+
toServer
;
}
console
.
log
(
'Query: '
+
toServer
)
;
request
(
toServer
,
function
(
err
,
response
,
body
)
{
var
string
=
body
.
toString
(
)
;
console
.
log
(
string
.
length
)
;
console
.
log
(
'\n\n'
)
return
rl
.
prompt
(
)
;
}
)
break
;
case
"help"
:
console
.
log
(
'\n'
)
;
console
.
log
(
'TinyCodeCLI Help :) '
.
magenta
)
;
console
.
log
(
'\n'
)
;
console
.
log
(
'g [keywords] -> git grep (searches active project code for keywords)'
)
;
console
.
log
(
'find [keywords] -> find (searches active project tree for files)'
)
;
console
.
log
(
'del [keywords] -> delete (shows files in table to select for deletion)'
)
;
console
.
log
(
'cd [project] -> changes project directory'
)
;
console
.
log
(
'lp -> lists active projects'
)
;
console
.
log
(
'ld -> console log active directory'
)
;
console
.
log
(
'sh [relative path and filename] -> prints out source code'
)
;
console
.
log
(
'git [command] [args] -> git on current folder'
)
;
console
.
log
(
'send [command] -> socket emit (Beta)'
)
;
console
.
log
(
'vps [cc|ccw|mem] -> executes vps commands on active project'
)
;
console
.
log
(
'ssh [kill-watches|ls] -> executes commands via ssh'
)
;
console
.
log
(
'\n'
)
;
return
rl
.
prompt
(
)
;
break
;
case
"vps"
:
var
cmd
=
null
;
switch
(
kw
[
1
]
)
{
case
"cc"
:
cmd
=
'clear-cache'
;
break
;
case
"ccw"
:
cmd
=
'clear-cache-watcher'
;
break
;
case
"mem"
:
cmd
=
'clear-cache memcache'
;
break
;
}
var
ssh
=
spawn
(
'ssh'
,
[
'daniel.vivid'
,
'cd www/'
+
activeProject
+
';'
,
'vps '
+
cmd
]
)
;
ssh
.
stdout
.
on
(
'data'
,
function
(
data
)
{
console
.
log
(
data
.
toString
(
)
)
;
}
)
ssh
.
stderr
.
on
(
'data'
,
function
(
err
)
{
console
.
error
(
err
.
toString
(
)
)
return
rl
.
prompt
(
)
;
}
)
ssh
.
on
(
'close'
,
function
(
)
{
console
.
log
(
'Child process closed \n'
)
;
return
rl
.
prompt
(
)
;
}
)
break
;
case
"ssh"
:
var
cmd
=
null
;
switch
(
kw
[
1
]
)
{
case
"kill-watches"
:
cmd
=
'killall inotifywait'
;
break
;
case
"ls"
:
cmd
=
'ls -lah'
;
break
;
}
var
ssh
=
spawn
(
'ssh'
,
[
'daniel.vivid'
,
'cd www/'
+
activeProject
+
';'
,
cmd
]
)
;
ssh
.
stdout
.
on
(
'data'
,
function
(
data
)
{
console
.
log
(
data
.
toString
(
)
)
;
}
)
ssh
.
stderr
.
on
(
'data'
,
function
(
err
)
{
console
.
error
(
err
.
toString
(
)
)
}
)
ssh
.
on
(
'close'
,
function
(
)
{
console
.
log
(
'Child process closed \n'
)
;
return
rl
.
prompt
(
)
;
}
)
break
;
default
:
return
rl
.
prompt
(
)
;
}
}
)
.
on
(
'SIGINT'
,
function
(
)
{
sigcount
++
;
if
(
sigcount
>=
2
)
{
util
.
puts
(
"Shutting down process ... "
.
cyan
)
;
util
.
puts
(
"So long and thanks for the fish :) "
.
green
.
bold
)
;
process
.
exit
(
0
)
;
}
else
{
util
.
puts
(
"\nPlease press CTRL+D again to exit"
.
magenta
)
}
}
)
.
on
(
"SIGCONT"
,
function
(
)
{
console
.
log
(
"got sig"
)
;
rl
.
prompt
(
)
;
}
)
app
.
get
(
'/*'
,
function
(
req
,
res
)
{
var
cmd
=
_
.
first
(
req
.
params
)
;
console
.
log
(
'\n'
)
;
console
.
log
(
'Received command '
+
cmd
.
magenta
+
' > query: '
+
_
.
values
(
req
.
query
)
.
join
(
','
)
.
cyan
)
;
switch
(
cmd
)
{
case
"watcher"
:
if
(
req
.
query
.
cacheType
===
'css'
)
{
io
.
sockets
.
emit
(
'com'
,
{
command
:
'stylesheet'
}
)
;
}
else
if
(
req
.
query
.
cacheType
===
'js'
)
{
io
.
sockets
.
emit
(
'com'
,
{
command
:
'jscript'
}
)
;
}
else
{
io
.
sockets
.
emit
(
'com'
,
{
command
:
'reload'
}
)
;
}
break
;
}
console
.
log
(
'\n'
)
;
rl
.
prompt
(
)
;
res
.
send
(
200
)
;
}
)
Back
|
FazBrowse Home
|
New Git URL