Created
February 21, 2015 00:15
-
-
Save JoshuaJones/b189b3d180450a633983 to your computer and use it in GitHub Desktop.
Example Grunt-Init Conditional Copy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"app/js/main-empty.js": "{% if (empty) { %}app/js/main.js{% } %}", | |
"app/js/main-skeleton.js": "{% if (!empty) { %}app/js/main.js{% } %}" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
// Template Infos | |
exports.description = 'Conditional copy example'; | |
exports.notes = 'This template is an example of conditional copying.'; | |
exports.warnOn = 'Gruntfile.js'; | |
exports.warnOn = 'package.json'; | |
// Template Init | |
exports.template = function (grunt, init, done) { | |
// Prompts | |
init.process({}, [ | |
init.prompt('name', 'ProjectName'), | |
init.prompt('description', 'Project description...'), | |
init.prompt('version', '0.0.1'), | |
init.prompt('homepage'), | |
{ | |
name: 'empty', | |
message: 'Empty main or setup?', | |
default: 'Y/n', | |
warning: '' | |
} | |
], function (err, props) { | |
var files; | |
// YepNope Dependencies | |
props.empty = /y/i.test(props.empty); | |
// Output Template | |
files = init.filesToCopy(props); | |
init.copyAndProcess(files, props); | |
init.writePackageJSON('package.json', props); | |
}) | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example for question here on copying files with
grunt-init