Skip to content

Instantly share code, notes, and snippets.

@JoshuaJones
Created February 21, 2015 00:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JoshuaJones/b189b3d180450a633983 to your computer and use it in GitHub Desktop.
Save JoshuaJones/b189b3d180450a633983 to your computer and use it in GitHub Desktop.
Example Grunt-Init Conditional Copy
{
"app/js/main-empty.js": "{% if (empty) { %}app/js/main.js{% } %}",
"app/js/main-skeleton.js": "{% if (!empty) { %}app/js/main.js{% } %}"
}
'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);
})
};
@JoshuaJones
Copy link
Author

Example for question here on copying files with grunt-init

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment