Not sure if this is possible, but I want to specify a variable to construct a destination path when using grunt-contrib-copy
like so:
module.exports = function(grunt) {
var $globals = {
buildPath: 'default'
};
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
copy: {
all: {
files: [{
expand: true,
cwd: 'source/',
src: ['file1.js', 'file2.js'],
dest: 'builds/' + $globals.buildPath + '/'
}]
}
}
});
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.registerTask('test', 'Build Test', function() {
$globals.buildPath = 'test';
grunt.task.run(['copy']);
});
};
In the above example, the copy task uses the initial value set in $globals.buildPath
, which is default
and it copies the files into the /builds/default/
directory instead of what I want, which is /builds/test/
I know that I can create a new subtask to achieve the result that I want, but doing it dynamically would make my Gruntfile.js smaller and easier to manage.