-
Notifications
You must be signed in to change notification settings - Fork 1
/
utility.coffee
60 lines (44 loc) · 1.4 KB
/
utility.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
path= require 'path'
EventEmitter= require('events').EventEmitter
chalk= require 'chalk'
class Utility
logColors: ['magenta','cyan','green','yellow']
logBgColors: ['bgMagenta','bgCyan','bgGreen','bgYellow']
constructor: ->
@i= 0
h1: (args...)->
console.log ''
console.log chalk.bold args...
log: (args...)->
[...,changeColor]= args
args= args[...-1] if changeColor is yes
console.log '7_P',@getColor(changeColor) args...
getColor: (changeColor=no)->
@i= 0 if @logColors[@i] is undefined
color= chalk[@logColors[@i]]
@i++ if changeColor is yes
color
getBgColor: (changeColor=no)->
@i= 0 if @logBgColors[@i] is undefined
color= chalk[@logBgColors[@i]]
@i++ if changeColor is yes
color
noop: ()->
noop= new EventEmitter
process.nextTick -> noop.emit 'close',0
noop
getSpecGlobs: (specDir,recursive=null,filename='*[sS]pec.coffee')->
specDir= path.join specDir,'**' if recursive?
globs= []
globs.push path.join specDir,filename
globs
getScriptGlobs: (srcDir,specDir,recursive=null,filename='*.coffee')->
cwd= '.' if specDir isnt '.'
srcDir= path.join(srcDir,'**') if recursive?
specDir= path.join(specDir,'**') if recursive?
globs= []
globs.push path.join(cwd,filename) if cwd?
globs.push path.join srcDir,filename
globs.push path.join specDir,filename
globs
module.exports= Utility