This repository has been archived by the owner on Aug 31, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 44
/
Gruntfile.coffee
112 lines (84 loc) · 4.17 KB
/
Gruntfile.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
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
#
# Copyright © 2015 by Redwood Labs
# All rights reserved.
#
fs = require 'fs'
########################################################################################################################
module.exports = (grunt)->
grunt.loadTasks tasks for tasks in grunt.file.expand './node_modules/grunt-*/tasks'
grunt.config.init
compress:
static:
options:
mode: 'gzip'
files: [
{expand: true, cwd:'./data', src:'**/*.cg', dest:'./dist/data'}
{expand: true, cwd:'./data', src:'**/*.json', dest:'./dist/data'}
]
clean:
dist: ['./dist']
modpack: ['./data/modpack.cg']
mochaTest:
options:
bail: true
color: true
reporter: 'dot'
require: [
'coffee-script/register'
'./test/test_helper.coffee'
]
verbose: true
src: ['./test/**/*.test.coffee']
symlink:
images:
files: [
{expand:true, cwd:'./data', src:'**/*.png', dest:'./dist/data'}
]
watch:
test:
files: ['./data/**/*.cg']
tasks: ['script:clear', 'script:compile-archive', 'mochaTest']
# Compound Tasks ###################################################################################################
grunt.registerTask 'default', 'run tests to verify data files',
['test']
grunt.registerTask 'pngcrush', 'compress images files to the maximum extent',
['script:pngcrush']
grunt.registerTask 'dist', 'build the project to be run from Amazon S3',
['clean', 'script:compile-archive', 'symlink:images', 'compress']
grunt.registerTask 'test', 'run unit tests',
['mochaTest']
grunt.registerTask 'upload:prod', 'upload the project to the production Amazon S3 environment',
['script:s3_upload:prod']
grunt.registerTask 'upload:staging', 'upload the project the staging Amazon S3 environment',
['script:s3_upload:staging']
# Code Tasks #######################################################################################################
grunt.registerTask 'use-local-deps', ->
grunt.file.mkdir './node_modules'
grunt.file.delete './node_modules/crafting-guide', force:true
grunt.file.delete './node_modules/crafting-guide-common', force:true
fs.symlinkSync '../../crafting-guide/', './node_modules/crafting-guide'
fs.symlinkSync '../../crafting-guide-common/', './node_modules/crafting-guide-common'
# Script Tasks #####################################################################################################
grunt.registerTask 'script:clear', 'clears the terminal screen', ->
done = this.async()
grunt.util.spawn cmd:'clear', opts:{stdio:'inherit'}, (error)-> done(error)
grunt.registerTask 'script:compile-archive', 'clears the terminal screen', ->
done = this.async()
grunt.util.spawn cmd:'scripts/compile-archive', opts:{stdio:'inherit'}, (error)-> done(error)
grunt.registerTask 'script:pngcrush', 'compresses all images using pngcrush', ->
done = this.async()
grunt.util.spawn cmd:'scripts/pngcrush', opts:{stdio:'inherit'}, (error)-> done(error)
grunt.registerTask 'script:s3_upload:prod', 'uploads all static content to S3', ->
done = this.async()
grunt.util.spawn cmd:'./scripts/s3_upload', args:['--prod'], opts:{stdio:'inherit'}, (error)-> done(error)
grunt.registerTask 'script:s3_upload:staging', 'uploads all static content to S3', ->
done = this.async()
grunt.util.spawn cmd:'./scripts/s3_upload', args:['--staging'], opts:{stdio:'inherit'}, (error)-> done(error)
# Command-Line Argument Processing #################################################################################
args = process.argv[..]
while args.length > 0
switch args[0]
when '--grep'
args.shift()
grunt.config.merge mochaTest:options:grep:args[0]
args.shift()