This repository was archived by the owner on Dec 4, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 50
/
Copy pathGruntfile.js
67 lines (52 loc) · 1.87 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
var path = require('path');
module.exports = function(grunt) {
grunt.registerTask('build', 'build the module', function() {
var done = this.async();
// runt titanium script to build the module
var ti = grunt.util.spawn({
cmd: 'ti',
args: ['build', '-p', 'android', '--build-only'],
opts: {
cwd: 'android'
}
}, function(error, result, code) {
if(error) {
grunt.fail.warn(error, code);
} else {
grunt.log.ok('build successful');
}
done(error, result);
});
ti.stdout.on('data', grunt.log.write);
ti.stderr.on('data', grunt.log.error);
});
grunt.registerTask('deploy', 'install the module', function() {
var done = this.async();
var version = grunt.file.readJSON('package.json').version;
var modPath = path.join(__dirname, 'android/dist/com.tripvi.drawerlayout-android-'+version+'.zip');
var install = grunt.util.spawn({
cmd: 'gittio',
args: ['install', '-g', modPath]
}, function(error, result, code) {
if(error) {
grunt.fail.warn(error, code);
} else {
grunt.log.ok('installed');
}
done(error, result);
});
install.stdout.on('data', grunt.log.write);
install.stderr.on('data', grunt.log.error);
});
grunt.registerTask('version', 'update version from package.json', function() {
// read files
var version = grunt.file.readJSON('package.json').version;
var manifest = grunt.file.read('android/manifest');
var readme = grunt.file.read('README.md');
// update manifest
grunt.file.write('android/manifest', manifest.replace(/^version.*$/m, "version: " + version));
// update readme
grunt.file.write('README.md', readme.replace(/gittio-[\d\.]{2,}-00B4CC\.svg/g, "gittio-" + version + "-00B4CC.svg"));
});
grunt.registerTask('default', ['version', 'build', 'deploy']);
};