-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGruntfile.js
125 lines (105 loc) · 2.92 KB
/
Gruntfile.js
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
117
118
119
120
121
122
123
124
125
'use strict';
var chalk = require('chalk');
var path = require('path');
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
jshint: {
options: {
jshintrc: true,
},
all: [
'Gruntfile.js',
'tasks/**/*.js'
]
},
clean: {
"test": [ './test/build' ],
"app": [ './test/fake-app/build', './test/fake-app/modules' ]
},
copy: {
"dependencies": {
files: {
'./test/fake-app/Resources/should.js': require.resolve('should/should'),
'./test/fake-app/Resources/ti-mocha.js': require.resolve('ti-mocha/ti-mocha')
}
}
},
titaniumifier: {
"module": {
files: { './test/build': 'test/fake-module' },
options: {
bare: false,
bundle: true,
module: true
}
},
"bare-module": {
files: { './test/build': 'test/fake-module' },
options: {
bare: true,
bundle: false,
module: true
}
}
},
unzip: {
"module": {
src: [
'test/build/renamed-module-commonjs-1.2.3.zip'
],
dest: 'test/fake-app'
}
},
titanium: {
options: {
command: 'build',
logLevel: (grunt.option('log-level') || 'info'),
projectDir: './test/fake-app',
success: '[TESTS ALL OK]',
failure: '[TESTS WITH FAILURES]'
},
"ios": {
options: {
platform: 'ios'
}
},
"droid": {
options: {
platform: 'android',
deviceId: grunt.option('device-id')
}
}
}
});
grunt.loadTasks('tasks');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-titanium');
grunt.loadNpmTasks('grunt-zip');
grunt.registerTask('check:build', function () {
var failures = [
'renamed-module-commonjs-1.2.3-bare.zip',
'renamed-module-commonjs-1.2.3.zip',
'renamed-module.js'
].reduce(function (failures, zipfile) {
if (grunt.file.isFile(path.resolve('test/build/', zipfile))) {
grunt.log.ok("File " + chalk.cyan(zipfile) + " correctly generated");
return failures;
}
else {
grunt.log.error("File " + chalk.cyan(zipfile) + " not generated");
return failures + 1;
}
}, 0);
if (failures) {
grunt.fail.fatal(failures + " file(s) had issues");
}
});
grunt.registerTask('test:build', [ 'clean:test', 'titaniumifier', 'check:build' ]);
grunt.registerTask('setup:app', [ 'clean:app', 'test:build', 'unzip:module', 'copy:dependencies' ]);
grunt.registerTask('test:ios', [ 'setup:app', 'titanium:ios' ]);
grunt.registerTask('test:droid', [ 'setup:app', 'titanium:droid' ]);
grunt.registerTask('default', [ 'jshint', 'test:build' ]);
};