UNPKG

1.87 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 commonjs module, including Nodeunit unit tests.';
12
13// Template-specific notes to be displayed before question prompts.
14exports.notes = '';
15
16// Any existing file or directory matching this wildcard will cause a warning.
17exports.warnOn = '*';
18
19// The actual init template.
20exports.template = function(grunt, init, done) {
21 // Grunt utilities.
22 var task = grunt.task;
23 var file = grunt.file;
24 var utils = grunt.utils;
25 var log = grunt.log;
26 var verbose = grunt.verbose;
27 var fail = grunt.fail;
28 var option = grunt.option;
29 var config = grunt.config;
30 var template = grunt.template;
31
32 grunt.helper('prompt', {}, [
33 // Prompt for these values.
34 grunt.helper('prompt_for', 'name'),
35 grunt.helper('prompt_for', 'description'),
36 grunt.helper('prompt_for', 'version'),
37 grunt.helper('prompt_for', 'repository'),
38 grunt.helper('prompt_for', 'homepage'),
39 grunt.helper('prompt_for', 'bugs'),
40 grunt.helper('prompt_for', 'licenses'),
41 grunt.helper('prompt_for', 'author_name'),
42 grunt.helper('prompt_for', 'author_email'),
43 grunt.helper('prompt_for', 'author_url'),
44 grunt.helper('prompt_for', 'node_version', '*'),
45 grunt.helper('prompt_for', 'main'),
46 grunt.helper('prompt_for', 'npm_test')
47 ], function(err, props) {
48 // Files to copy (and process).
49 var files = init.filesToCopy(props);
50
51 // Add properly-named license files.
52 init.addLicenseFiles(files, props.licenses);
53
54 // Actually copy (and process) files.
55 init.copyAndProcess(files, props);
56
57 // Generate package.json file.
58 init.writePackageJSON('package.json', props);
59
60 // All done!
61 done();
62 });
63
64};