This repository has been archived by the owner on Jun 3, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 32
/
Cakefile
64 lines (50 loc) · 2.29 KB
/
Cakefile
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
fs = require "fs"
path = require "path"
child_process = require "child_process"
spawn = (procName, optArray, silent=false) ->
proc = child_process.spawn procName, optArray
unless silent
proc.stdout.on 'data', (data) -> process.stdout.write data
proc.stderr.on 'data', (data) -> process.stderr.write data
proc
# visitor will get passed the file path as a parameter
visitDirectory = (directory, visitor) ->
fs.readdirSync(directory).forEach (filename) ->
filepath = path.join directory, filename
if (fs.statSync filepath).isDirectory()
return visitDirectory filepath, visitor
return unless (fs.statSync filepath).isFile()
visitor(filepath)
task "build", "compile all coffeescript files to javascript", ->
coffee = spawn "coffee", ["-c", __dirname]
coffee.on 'exit', (returnCode) -> process.exit returnCode
task "clean", "removes any js files which were compiled from coffeescript", ->
visitDirectory __dirname, (filepath) ->
return unless (path.extname filepath) == ".js"
directory = path.dirname filepath
# Check if there exists a corresponding .coffee file
try
coffeeFile = fs.statSync path.join directory, "#{path.basename filepath, ".js"}.coffee"
catch _
return
fs.unlinkSync filepath if coffeeFile.isFile()
task "autobuild", "continually rebuild coffeescript files using coffee --watch", ->
coffee = spawn "coffee", ["-cw", __dirname]
task "package", "create release zip", ->
invoke "build"
fs.mkdirSync 'releases' if !fs.existsSync 'releases'
origManifestText = fs.readFileSync "manifest.json"
manifest = JSON.parse origManifestText
get_revision = child_process.exec "git log --oneline | wc -l", (error, stdout, stderr) ->
revnum = stdout.trim()
if (error != null)
console.log('exec error: ' + error)
else
write_manifest(revnum)
zip_release = child_process.exec "zip -r 'releases/Syntaxtic_v#{manifest.version}.zip' . -x \\*.coffee \\*.git\\* \\*releases\\* Cakefile README.md node_modules\\* package.json yarn.lock", (error, stdout, stderr) ->
if (error != null)
console.log('exec error: ' + error)
fs.writeFileSync "manifest.json", origManifestText
write_manifest = (revnum) ->
manifest.version = '4.0.' + revnum
fs.writeFileSync "manifest.json", JSON.stringify manifest