Skip to content

Instantly share code, notes, and snippets.

@markdboyd
Created April 30, 2015 05:10
Show Gist options
  • Save markdboyd/2aba928f6fb2e7ab50a7 to your computer and use it in GitHub Desktop.
Save markdboyd/2aba928f6fb2e7ab50a7 to your computer and use it in GitHub Desktop.
Add file copy support for GDT on Windows
module.exports = function(grunt) {
/**
* Define "copy" tasks.
*
* grunt copy:modules
* Copies modules from src/modules to sites/all/modules/custom in
* the build/html directory.
*
* grunt copy:profiles
* Copies profiles from src/profiles to profiles in the build/html
* directory.
*
* grunt copy:sites
* Copies directories from src/sites (except for src/sites/all
* since the all directory needs to be preserved) to sites
* in the build/html directry.
*
* grunt copy:themes
* Copy themes from src/themes to sites/all/themes/custom in the
* build/html directory.
*/
if (grunt.config.get('platform') == 'win32') {
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.config(['copy', 'modules'], {
files: [{
expand: true,
cwd: '<%= config.srcPaths.drupal %>/modules',
src: ['**'],
dest: '<%= config.buildPaths.html %>/sites/all/modules/custom'
}]
});
grunt.config(['copy', 'sites'], {
files: [{
expand: true,
cwd: '<%= config.srcPaths.drupal %>/sites',
src: ['**'],
dest: '<%= config.buildPaths.html %>/sites',
filter: function (path) {
return (path !== '<%= config.srcPaths.drupal %>/sites/all');
}
}]
});
grunt.config(['copy', 'themes'], {
files: [{
expand: true,
cwd: '<%= config.srcPaths.drupal %>/themes',
src: ['**'],
dest: '<%= config.buildPaths.html %>/sites/all/themes/custom'
}]
});
grunt.config(['copy', 'profiles'], {
files: [{
expand: true,
cwd: '<%= config.srcPaths.drupal %>/profiles',
src: ['**'],
dest: '<%= config.buildPaths.html %>/profiles',
}]
});
grunt.config(['copy', 'libraries'], {
files: [{
expand: true,
cwd: '<%= config.buildPaths.html %>/profiles/panopoly/libraries',
src: ['**'],
dest: '<%= config.buildPaths.html %>/sites/all/libraries',
filter: 'isDirectory'
}]
});
grunt.registerTask('create:modules', ['copy:modules']);
grunt.registerTask('create:sites', ['copy:sites']);
grunt.registerTask('create:themes', ['copy:themes']);
grunt.registerTask('create:profiles', ['copy:profiles']);
grunt.registerTask('create:libraries', ['copy:libraries']);
}
};
module.exports = function(grunt) {
// Load all plugins and tasks defined by the grunt-drupal-tasks package.
require('grunt-drupal-tasks')(grunt);
// Get the OS and set it as a variable.
var os = require('os');
var platform = os.platform();
grunt.config('platform', platform);
// Load additional custom tasks.
grunt.loadTasks(__dirname + '/grunt/tasks');
// Define the default task to fully build and configure the project.
grunt.config(['mkdir', 'libraries'], {
options: {
create: [
'<%= config.buildPaths.html %>/sites/all/libraries',
]
}
});
var tasksDefault = [
'validate',
'newer:drushmake:default',
'create:profiles',
'mkdir:libraries',
'create:libraries',
'clean:sites',
'create:sites',
'mkdir:files',
'create:modules',
'create:themes'
];
if (grunt.config.get(['composer', 'install'])) {
tasksDefault.unshift('composer:install');
}
if (grunt.task.exists('compile-theme')) {
tasksDefault.push('compile-theme');
}
if (grunt.task.exists('bundleInstall')) {
tasksDefault.unshift('bundleInstall');
}
grunt.registerTask('default', tasksDefault);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment