UNPKG

2.24 kBJavaScriptView Raw
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.
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/gruntjs/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
23 grunt.helper('prompt', {type: 'grunt'}, [
24 // Prompt for these values.
25 grunt.helper('prompt_for', 'name', function(value, data, done) {
26 // Prepend "grunt-" to default name if not already there.
27 data.short_name = value;
28 value = data.full_name = 'grunt-' + value;
29 // if (!/^grunt-/.test(value)) { value = 'grunt-' + value; }
30 done(null, value);
31 }),
32 grunt.helper('prompt_for', 'description', 'The best sample grunt tasks ever.'),
33 grunt.helper('prompt_for', 'version'),
34 grunt.helper('prompt_for', 'repository'),
35 grunt.helper('prompt_for', 'homepage'),
36 grunt.helper('prompt_for', 'bugs'),
37 grunt.helper('prompt_for', 'licenses'),
38 grunt.helper('prompt_for', 'author_name'),
39 grunt.helper('prompt_for', 'author_email'),
40 grunt.helper('prompt_for', 'author_url'),
41 grunt.helper('prompt_for', 'grunt_version'),
42 grunt.helper('prompt_for', 'node_version', '*')
43 ], function(err, props) {
44 // Set a few grunt-plugin-specific properties.
45 props.main = 'grunt.js';
46 props.npm_test = 'grunt test';
47 props.bin = 'bin/' + props.name;
48 props.keywords = ['gruntplugin'];
49
50 // Files to copy (and process).
51 var files = init.filesToCopy(props);
52
53 // Add properly-named license files.
54 init.addLicenseFiles(files, props.licenses);
55
56 // Actually copy (and process) files.
57 init.copyAndProcess(files, props);
58
59 // Generate package.json file.
60 init.writePackageJSON('package.json', props);
61
62 // All done!
63 done();
64 });
65
66};