-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmake.coffee
More file actions
66 lines (54 loc) · 1.93 KB
/
make.coffee
File metadata and controls
66 lines (54 loc) · 1.93 KB
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
require 'shelljs/make'
fs = require 'fs'
# Config
config = {
srcDir: "src"
, mainDir: "src/main"
, testDir: "src/test"
, buildDir: "build"
, globalReqs: ["supervisor", "mocha", "docco", "nodemon"]
}
# Helpers
isRootInUbuntu = -> exec("whoami", {silent:true}).output == 'root'
needsSudo = -> (process.platform == 'linux') && (exec("hostname", {silent:true}).output.indexOf('c9-node') == -1) #detects if we are on cloud9
isEnoughPriv = -> ( !needsSudo() || isRootInUbuntu() )
globalPkgInstallCommand = (pkg, withSudo) -> (if(withSudo) then "sudo " else "") + "npm install #{pkg} -g"
req = (cmd) ->
w = which cmd
if not w
echo "\"#{cmd}\" is required. Please make sure that it is properly installed."
return w != null
# Targets
target.ensureGlobalReqs = ->
notInstalled = config.globalReqs.filter( (item) -> not which(item) )
if(notInstalled.length > 0)
if(!isEnoughPriv())
echo("Does not have enough priviledge to install global packages")
echo("Please run 'sudo ./run ensureGlobalReqs' to install needed global pkgs")
exit(1)
notInstalled.forEach( (item) ->
exec(globalPkgInstallCommand(item, needsSudo()))
)
target.npmInstall = ->
exec("npm install")
target.ensureReqs = ->
target.ensureGlobalReqs()
target.npmInstall()
target.autotest = ->
scripts = "
require('shelljs/global');\n
\n
console.log('\\033[2J\\033[0f'); //Clear Screen\n
console.log('Restarting autotest...');\n
\n
exec('mocha --reporter min --compilers coffee:coffee-script --colors #{config.testDir}/*_test.coffee');\n
"
fs.writeFileSync("#{config.buildDir}/autotest.js", scripts)
exec("nodemon --watch #{config.srcDir} -e js,coffee #{config.buildDir}/autotest.js")
target.test = ->
exec("mocha --reporter spec --compilers coffee:coffee-script --colors #{config.testDir}/*_test.coffee")
target.all = ->
target.dev()
target.dev = ->
target.ensureReqs()
exec("supervisor -w src -e 'js|coffee' app")