Tizen 2.1 base
[platform/framework/web/web-ui-fw.git] / libs / js / jquery-mobile-1.2.0 / node_modules / grunt / tasks / init / gruntfile.js
1 /*
2  * grunt
3  * http://gruntjs.com/
4  *
5  * Copyright (c) 2012 "Cowboy" Ben Alman
6  * Licensed under the MIT license.
7  * https://github.com/gruntjs/grunt/blob/master/LICENSE-MIT
8  */
9
10 // Basic template description.
11 exports.description = 'Create a basic grunt.js gruntfile.';
12
13 // Template-specific notes to be displayed before question prompts.
14 exports.notes = 'This template tries to guess file and directory paths, but ' +
15   'you will most likely need to edit the generated grunt.js file before ' +
16   'running grunt. _If you run grunt after generating grunt.js, and grunt ' +
17   'exits with errors, edit the grunt.js file!_';
18
19 // Any existing file or directory matching this wildcard will cause a warning.
20 exports.warnOn = 'grunt.js';
21
22 // The actual init template.
23 exports.template = function(grunt, init, done) {
24
25   grunt.helper('prompt', {}, [
26     // Prompt for these values.
27     {
28       name: 'dom',
29       message: 'Is the DOM involved in ANY way?',
30       default: 'Y/n',
31       warning: 'Yes: QUnit unit tests + JSHint "browser" globals. No: Nodeunit unit tests.'
32     },
33     {
34       name: 'min_concat',
35       message: 'Will files be concatenated or minified?',
36       default: 'Y/n',
37       warning: 'Yes: min + concat tasks. No: nothing to see here.'
38     },
39     {
40       name: 'package_json',
41       message: 'Will you have a package.json file?',
42       default: 'Y/n',
43       warning: 'This changes how filenames are determined and banners are generated.'
44     }
45   ], function(err, props) {
46     props.dom = /y/i.test(props.dom);
47     props.min_concat = /y/i.test(props.min_concat);
48     props.package_json = /y/i.test(props.package_json);
49     props.test_task = props.dom ? 'qunit' : 'test';
50     props.file_name = props.package_json ? '<%= pkg.name %>' : 'FILE_NAME';
51
52     // Find the first `preferred` item existing in `arr`.
53     function prefer(arr, preferred) {
54       for (var i = 0; i < preferred.length; i++) {
55         if (arr.indexOf(preferred[i]) !== -1) {
56           return preferred[i];
57         }
58       }
59       return preferred[0];
60     }
61
62     // Guess at some directories, if they exist.
63     var dirs = grunt.file.expandDirs('*').map(function(d) { return d.slice(0, -1); });
64     props.lib_dir = prefer(dirs, ['lib', 'src']);
65     props.test_dir = prefer(dirs, ['test', 'tests', 'unit', 'spec']);
66
67     // Maybe this should be extended to support more libraries. Patches welcome!
68     props.jquery = grunt.file.expandFiles('**/jquery*.js').length > 0;
69
70     // Files to copy (and process).
71     var files = init.filesToCopy(props);
72
73     // Actually copy (and process) files.
74     init.copyAndProcess(files, props);
75
76     // All done!
77     done();
78   });
79
80 };