UNPKG

2.52 kBJavaScriptView Raw
1/*
2 * grunt
3 * https://github.com/cowboy/grunt
4 *
5 * Copyright (c) 2012 "Cowboy" Ben Alman
6 * Licensed under the MIT license.
7 * http://benalman.com/about/license/
8 */
9
10// Basic template description.
11exports.description = 'Create a grunt plugin, including Nodeunit unit tests.';
12
13// Template-specific notes to be displayed before question prompts.
14exports.notes = 'The grunt plugin system is still under development. For ' +
15 'more information, see the docs at https://github.com/cowboy/grunt/blob/master/docs/plugins.md';
16
17// Any existing file or directory matching this wildcard will cause a warning.
18exports.warnOn = '*';
19
20// The actual init template.
21exports.template = function(grunt, init, done) {
22 // Grunt utilities.
23 var task = grunt.task;
24 var file = grunt.file;
25 var utils = grunt.utils;
26 var log = grunt.log;
27 var verbose = grunt.verbose;
28 var fail = grunt.fail;
29 var option = grunt.option;
30 var config = grunt.config;
31 var template = grunt.template;
32
33 grunt.helper('prompt', {type: 'grunt'}, [
34 // Prompt for these values.
35 grunt.helper('prompt_for', 'name', function(value, data, done) {
36 // Prepend "grunt-" to default name if not already there.
37 data.short_name = value;
38 value = data.full_name = 'grunt-' + value;
39 // if (!/^grunt-/.test(value)) { value = 'grunt-' + value; }
40 done(null, value);
41 }),
42 grunt.helper('prompt_for', 'description', 'The best sample grunt tasks ever.'),
43 grunt.helper('prompt_for', 'version'),
44 grunt.helper('prompt_for', 'repository'),
45 grunt.helper('prompt_for', 'homepage'),
46 grunt.helper('prompt_for', 'bugs'),
47 grunt.helper('prompt_for', 'licenses'),
48 grunt.helper('prompt_for', 'author_name'),
49 grunt.helper('prompt_for', 'author_email'),
50 grunt.helper('prompt_for', 'author_url'),
51 grunt.helper('prompt_for', 'grunt_version'),
52 grunt.helper('prompt_for', 'node_version', '*')
53 ], function(err, props) {
54 // Set a few grunt-plugin-specific properties.
55 props.main = 'grunt.js';
56 props.npm_test = 'grunt test';
57 props.bin = 'bin/' + props.name;
58 props.dependencies = {grunt: props.grunt_version};
59
60 // Files to copy (and process).
61 var files = init.filesToCopy(props);
62
63 // Add properly-named license files.
64 init.addLicenseFiles(files, props.licenses);
65
66 // Actually copy (and process) files.
67 init.copyAndProcess(files, props);
68
69 // Generate package.json file.
70 init.writePackageJSON('package.json', props);
71
72 // All done!
73 done();
74 });
75
76};