UNPKG

2 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 Node.js module, including Nodeunit unit tests.';
12
13// Template-specific notes to be displayed before question prompts.
14exports.notes = '_Project name_ shouldn\'t contain "node" or "js" and should ' +
15 'be a unique ID not already in use at search.npmjs.org.';
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: 'node'}, [
34 // Prompt for these values.
35 grunt.helper('prompt_for', 'name'),
36 grunt.helper('prompt_for', 'description'),
37 grunt.helper('prompt_for', 'version'),
38 grunt.helper('prompt_for', 'repository'),
39 grunt.helper('prompt_for', 'homepage'),
40 grunt.helper('prompt_for', 'bugs'),
41 grunt.helper('prompt_for', 'licenses'),
42 grunt.helper('prompt_for', 'author_name'),
43 grunt.helper('prompt_for', 'author_email'),
44 grunt.helper('prompt_for', 'author_url'),
45 grunt.helper('prompt_for', 'node_version'),
46 grunt.helper('prompt_for', 'main'),
47 grunt.helper('prompt_for', 'npm_test')
48 ], function(err, props) {
49 // Files to copy (and process).
50 var files = init.filesToCopy(props);
51
52 // Add properly-named license files.
53 init.addLicenseFiles(files, props.licenses);
54
55 // Actually copy (and process) files.
56 init.copyAndProcess(files, props);
57
58 // Generate package.json file.
59 init.writePackageJSON('package.json', props);
60
61 // All done!
62 done();
63 });
64
65};