UNPKG

2.97 kBJavaScriptView Raw
1/*global module, require */
2/*jshint camelcase: false */
3
4module.exports = function (grunt) {
5 'use strict';
6
7 // show elapsed time at the end
8 require('time-grunt')(grunt);
9 // load all grunt tasks
10 require('load-grunt-tasks')(grunt);
11
12 // configurable paths
13 var yeomanConfig = {
14 app: 'app',
15 dist: 'dist'
16 };
17 // Project configuration.
18 grunt.initConfig({
19 yeoman: yeomanConfig,
20 jshint: {
21 gruntfile: {
22 src: 'Gruntfile.js'
23 }
24 },
25 watch: {
26 cordova: {
27 files: '<%%= yeoman.app %>/www/**',
28 tasks: ['build', 'emulate']
29 }
30 },
31 cordovacli: {
32 options: {
33 path: '<%%= yeoman.app %>'
34 },
35 cordova: {
36 options: {
37 command: ['create', 'platform', 'plugin'],
38 platforms: <%= platforms %>,
39 plugins: <%= plugins %>,
40 id: '<%= appId %>',
41 name: '<%= _.slugify(appName) %>'
42 }
43 },
44 build: {
45 options: {
46 command: 'build'
47 }
48 },
49 emulate: {
50 options: {
51 command: 'emulate'
52 }
53 },
54 run: {
55 options: {
56 command: 'run'
57 }
58 },
59 prepare: {
60 options: {
61 command: 'prepare'
62 }
63 },
64 compile: {
65 options: {
66 command: 'compile'
67 }
68 }
69 },
70 clean: {
71 cordova: {
72 files: [{
73 dot: true,
74 src: [
75 '<%%= yeoman.app %>'
76 ]
77 }]
78 }
79 }
80 });
81
82 grunt.registerTask('default', ['build']);
83 grunt.registerTask('lint', ['jshint']);
84 grunt.registerTask('server', ['build', 'emulate', 'watch:cordova']);
85
86
87
88
89 grunt.task.registerTask('build', 'Builds a Cordova App', function () {
90 var check;
91
92 check = (yeomanConfig.app + '/.cordova/config.json');
93
94 if (grunt.file.exists(check)) {
95 grunt.log.writeln(check + ' exists, only do build');
96 grunt.task.run(['cordovacli:build']);
97 } else {
98 grunt.log.writeln(check + ' does not exists, creating app and building');
99 grunt.task.run(['cordovacli:cordova', 'cordovacli:build']);
100 }
101
102 });
103
104 grunt.registerTask('prepare', ['cordovacli:prepare']);
105 grunt.registerTask('compile', ['cordovacli:compile']);
106 grunt.registerTask('emulate', ['cordovacli:emulate']);
107 grunt.registerTask('run', ['cordovacli:run']);
108 grunt.registerTask('demo', ['build', 'emulate']);
109
110};
111
\No newline at end of file