forked from tidev/titanium-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
76 lines (62 loc) · 2.02 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
module.exports = function (grunt) {
// Project configuration.
grunt.initConfig({
appcJs: {
src: ['apidoc/**/*.js', '!apidoc/node_modules/**']
},
clangFormat: {
src: [] // unused ATM
}
});
// Load grunt plugins for modules
grunt.loadNpmTasks('grunt-mocha-test');
grunt.loadNpmTasks('grunt-appc-js');
grunt.loadNpmTasks('grunt-clang-format');
grunt.loadNpmTasks('grunt-contrib-clean');
// register tasks
grunt.registerTask('lint', ['appcJs']);
// register tasks
grunt.registerTask('format', ['clangFormat']);
// register tasks
grunt.registerTask('default', ['lint']);
// update npm deps task
grunt.registerTask('update-npm-deps', 'Updated NPM dependencies', function () {
var done = this.async(),
exec = require('child_process').exec,
fs = require('fs'),
path = require('path');
if (parseInt(process.versions.modules) < 46) {
return done(new Error('You must run this using Node.js 4.0. Sorry.'));
}
grunt.log.writeln('Removing old Node modules');
function rm(dir, ignore) {
fs.existsSync(dir) && fs.readdirSync(dir).forEach(function (name) {
var file = path.join(dir, name);
if (ignore && ignore.indexOf(name) !== -1) {
grunt.log.writeln('Skipping ' + name);
return;
} else if (ignore) {
grunt.log.writeln('Removing ' + name);
}
if (fs.existsSync(file) && fs.statSync(file).isDirectory() && (!ignore || ignore.indexOf(name) === -1)) {
rm(file);
fs.rmdirSync(file);
} else {
fs.unlinkSync(file);
}
});
}
rm(path.join(__dirname, 'node_modules'), ['titanium-sdk']);
grunt.log.writeln('Running npm install');
exec('npm install', function (err, stdout, stderr) {
if (err) {
return done(err);
}
grunt.log.writeln('Building node-ios-device binaries');
exec('make', { cwd: path.join(__dirname, 'node_modules', 'ioslib', 'node_modules', 'node-ios-device') }, function (err, stdout, stderr) {
rm(path.join(__dirname, 'node_modules', 'ioslib', 'node_modules', 'node-ios-device', 'build'));
done(err);
});
});
});
};