forked from tonylukasavage/ti-mocha
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
58 lines (51 loc) · 1.51 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
var build = require('./lib/build'),
C = require('./lib/constants'),
fs = require('fs'),
path = require('path');
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
mochaTest: {
options: {
timeout: 3000,
ignoreLeaks: false,
reporter: 'spec'
},
src: ['test/*_test.js']
},
jshint: {
options: {
jshintrc: true
},
src: ['lib/*.js', 'test/*.js']
},
ti_run: {
app: {
files: {
'tmp/app/Resources': ['ti-mocha.js', 'test/app.js']
}
}
},
clean: {
src: ['build', 'tmp']
}
});
// Load grunt plugins for modules
grunt.loadNpmTasks('grunt-mocha-test');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-titanium');
// run build
grunt.registerTask('_build', 'finalize ti-mocha.js release file', function() {
grunt.log.write('Reading build ti-mocha.js...');
var contents = fs.readFileSync(C.BUILD_FILE, 'utf8');
grunt.log.ok();
grunt.log.write('Copying "' + path.relative('.', C.BUILD_FILE) + '" to "' + path.relative('.', C.RELEASE_FILE) + '"...');
fs.writeFileSync(C.RELEASE_FILE, contents);
fs.chmodSync(C.RELEASE_FILE, fs.lstatSync(C.BUILD_FILE).mode);
grunt.log.ok();
});
// lint and test node and titanium
grunt.registerTask('test', ['clean', 'mochaTest']);
grunt.registerTask('default', ['clean', 'jshint', 'mochaTest', '_build', 'clean', 'ti_run']);
};