-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathGruntfile.coffee
116 lines (108 loc) · 3.48 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
113
114
115
116
module.exports = (grunt) ->
grunt.initConfig
pkg: grunt.file.readJSON 'package.json'
gaslib: 'lib/gas-underscore-v<%= pkg.version %>'
gastestlib: 'lib/gas-underscore-test-v<%= pkg.version %>'
concat:
underscore_tests:
src: [
'temp/arrays.js'
'temp/chaining.js'
'temp/collections.js'
'temp/functions.js'
'temp/objects.js'
'temp/utility.js'
]
dest: '<%= gastestlib %>/tests.gs.js'
copy:
sources:
files: [
{
src: 'vendor/underscore/underscore.js'
dest: '<%= gaslib %>/underscore.gs.js'
}
{
src: 'src/main.js'
dest: '<%= gaslib %>/main.gs.js'
}
{
src: 'src/test.js'
dest: '<%= gastestlib %>/test.gs.js'
}
]
shell:
init:
command: 'git submodule update --init'
options:
stdout: true
stderr: true
failOnError: true
npm_update:
command: 'npm update'
options:
stdout: true
stderr: true
failOnError: true
pull_underscore:
command: [
'git checkout master'
'git pull origin master'
].join('&&')
options:
execOptions:
cwd: 'vendor/underscore'
stdout: true
stderr: true
failOnError: true
recursive_pull:
command: 'git pull --recurse-submodules'
options:
stdout: true
stderr: true
failOnError: true
'string-replace':
tests:
files: [
'temp/arrays.js': 'vendor/underscore/test/arrays.js'
'temp/chaining.js': 'vendor/underscore/test/chaining.js'
'temp/collections.js': 'vendor/underscore/test/collections.js'
'temp/functions.js': 'vendor/underscore/test/functions.js'
'temp/objects.js': 'vendor/underscore/test/objects.js'
'temp/utility.js': 'vendor/underscore/test/utility.js'
]
options:
replacements: [
# Wraps tests in global functions so that they can be run in Google Apps Script
pattern: /\(function\(\) \{([^]+)module\((\'|\")(\w+)([^\"\']*)(?:\'|\")([^]+)\}\(\)\);\n*$/mg
replacement: 'function test$3() {$1module($2$3$4$2$5};\n'
,
pattern: /(var _ = typeof[^;]+;)/
replacement: '//$1'
, # Ignore tests that break because of peculiarities with Google Apps Script
pattern: /([ ]+)(bound = _\.bind\(func, null.*\);)\s+(var.*;)\s+(\/\/.*)\s+(ok.*;)/m
replacement: '$1// Commented because of https://code.google.com/p/google-apps-script-issues/issues/detail?id=1718\n$1//$2\n$1//$3\n$1$4\n$1//$5'
, # Ignore asynchronous tests (due to the lack of setTimeout in Google Apps Script)
pattern: /([ ]+asyncTest\([^]+;)(?=\s+test\(\'once\')/m
replacement: '/*\n$1\n*/'
,
pattern: /(QUnit.config.async[^;]+;)/
replacement: '//$1'
]
grunt.registerTask 'build', [
'shell:init'
'copy'
'string-replace'
'concat'
]
grunt.registerTask 'update', [
'shell:npm_update'
'shell:pull_underscore'
'shell:recursive_pull'
]
grunt.registerTask 'default', [
'build'
]
grunt.loadNpmTasks 'grunt-contrib-concat'
grunt.loadNpmTasks 'grunt-contrib-copy'
grunt.loadNpmTasks 'grunt-shell'
grunt.loadNpmTasks 'grunt-string-replace'