I am using load-grunt-config and I have a simple copy task setup like this inside my Gruntfile.js,
grunt.registerTask('copy-css', 'Blah.', ['copy:css'])
And then inside my copy.js file I have this (ignore the invalid code. The copy task is working fine, I am just setting up this example).
'use strict';
module.exports = function(grunt, options) {
if(!grunt.file.exists(foldername)) {
//I NEED TO RUN A PROMPT HERE BUT THIS IS NOT WORKING
grunt.task.run('prompt:directory-exists');
}
return {
'css': {
'files': [{
}]
}
};
};
My prompt task looks something like this,
'use strict';
module.exports = {
'directory-exists': {
'options': {
'questions': [{
'type': 'confirm',
'message': 'That folder already exists. Are you sure you want to continue?',
'choices': ['Yes (overwrite my project files)', 'No (do nothing)']
}]
}
}
};
Grunt is not finding this task though, which I think has to do with how I am calling it considering I am using load-grunt-config.
I ended up going about this differenlty. Instead of checking to see if the directory exists, I am just getting a list of the directories, passing that to the prompt question and forcing the user to choose a directory before it ever gets to the copy task.