forked from gruntjs/grunt-init-gruntfile
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtemplate.js
More file actions
89 lines (73 loc) · 2.8 KB
/
template.js
File metadata and controls
89 lines (73 loc) · 2.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/*
* grunt-init-gruntfile
* https://gruntjs.com/
*
* Copyright (c) 2016 "Cowboy" Ben Alman, contributors
* Licensed under the MIT license.
*/
'use strict';
// Basic template description.
exports.description = 'Create a basic Gruntfile.';
// Template-specific notes to be displayed before question prompts.
exports.notes = 'This template tries to guess file and directory paths, but ' +
'you will most likely need to edit the generated Gruntfile.js file before ' +
'running grunt. _If you run grunt after generating the Gruntfile, and ' +
'it exits with errors, edit the file!_';
// Any existing file or directory matching this wildcard will cause a warning.
exports.warnOn = 'Gruntfile.js';
// The actual init template.
exports.template = function(grunt, init, done) {
init.process({}, [
// Prompt for these values.
{
name: 'package_json',
message: 'Will you have a package.json file?',
default: 'Y/n',
warning: 'This changes how filenames are determined and banners are generated.'
}
], function(err, props) {
props.package_json = /y/i.test(props.package_json);
props.file_name = props.package_json ? '<%= pkg.name %>' : 'FILE_NAME';
// Find the first `preferred` item existing in `arr`.
function prefer(arr, preferred) {
for (var i = 0; i < preferred.length; i++) {
if (arr.indexOf(preferred[i]) !== -1) {
return preferred[i];
}
}
return preferred[0];
}
// Guess at some directories, if they exist.
var dirs = grunt.file.expand({filter: 'isDirectory'}, '*').map(function(d) { return d.slice(0, -1); });
props.lib_dir = prefer(dirs, ['lib', 'src']);
// Maybe this should be extended to support more libraries. Patches welcome!
props.jquery = grunt.file.expand({filter: 'isFile'}, '**/jquery*.js').length > 0;
// Files to copy (and process).
var files = init.filesToCopy(props);
// Actually copy (and process) files.
init.copyAndProcess(files, props);
// If is package_json true, generate package.json
if (props.package_json) {
var devDependencies = {
'grunt': '~1.6.1',
"grunt-contrib-jshint": "^3.2.0",
'grunt-contrib-concat': '~2.1.0',
"grunt-contrib-sass": "^2.0.0",
"grunt-contrib-uglify": "^5.2.2",
"@fortawesome/fontawesome-free": "^6.6.0",
"@fontsource-variable/material-symbols-sharp": "^5.2.27",
"@fontsource-variable/manrope": "^5.2.8",
"@fontsource-variable/quicksand": "^5.2.8",
"@fontsource/poppins": "^5.2.7",
"bootstrap": "^5.3.3",
};
// Generate package.json file, used by npm and grunt.
init.writePackageJSON('package.json', {
node_version: '>= 0.10.0',
devDependencies: devDependencies
});
}
// All done!
done();
});
};