From 8451a4d64bb87fb4f03be923eb6818e85ef0683c Mon Sep 17 00:00:00 2001 From: Joe Turgeon Date: Thu, 2 Mar 2017 18:15:00 -0600 Subject: [PATCH 1/2] Initialize grunt-composer after configuration to enable multi task mode and task-specific configuration. Updating default tasks for multi task mode. --- bootstrap.js | 6 +++--- tasks/composer.js | 37 ++++++++++++++++++++----------------- 2 files changed, 23 insertions(+), 20 deletions(-) diff --git a/bootstrap.js b/bootstrap.js index 88fc1ce3..ef4169b6 100644 --- a/bootstrap.js +++ b/bootstrap.js @@ -62,13 +62,13 @@ module.exports = function(grunt) { if (grunt.file.exists('./composer.lock') && grunt.config.get(['composer', 'install'])) { if (grunt.config.get(['composer', 'drupal-scaffold'])) { // Manually run `composer drupal-scaffold` since this is only automatically run on update. - tasksDefault.unshift('composer:drupal-scaffold'); + tasksDefault.unshift('composer:drupal-scaffold:drupal-scaffold'); } // Run `composer install` if there is already a lock file. Updates should be explicit once this file exists. - tasksDefault.unshift('composer:install'); + tasksDefault.unshift('composer:install:install'); } else if (grunt.config.get(['composer', 'update'])) { // Run `composer update` if no lock file exists. This forces `composer drupal-scaffold` to run. - tasksDefault.unshift('composer:update'); + tasksDefault.unshift('composer:update:update'); } if (grunt.task.exists('compile-theme')) { diff --git a/tasks/composer.js b/tasks/composer.js index 5ef8a39b..d3ab219b 100644 --- a/tasks/composer.js +++ b/tasks/composer.js @@ -6,28 +6,31 @@ module.exports = function(grunt) { * exists in the project directory. */ if (require('fs').existsSync('./composer.json')) { - grunt.loadNpmTasks('grunt-composer'); var Help = require('../lib/help')(grunt); - grunt.config(['composer', 'install'], { - options: { - flags: [ - 'no-interaction', - 'no-progress', - 'prefer-dist' - ] - } - }); - grunt.config(['composer', 'update'], { - options: { - flags: [ - 'no-interaction', - 'no-progress', - 'prefer-dist' - ] + grunt.config('composer', { + install: { + options: { + flags: [ + 'no-interaction', + 'no-progress', + 'prefer-dist' + ] + } + }, + update: { + options: { + flags: [ + 'no-interaction', + 'no-progress', + 'prefer-dist' + ] + } } }); + grunt.loadNpmTasks('grunt-composer'); + // Add the drupal-scaffold task if it is defined in the `composer.json`. var composer = JSON.parse(require('fs').readFileSync('./composer.json', 'utf8')); if (typeof composer.scripts !== 'undefined' && 'drupal-scaffold' in composer.scripts) { From 0271e9e6a564c6d60bb8d82027610bf4cfff56e4 Mon Sep 17 00:00:00 2001 From: Joe Turgeon Date: Thu, 2 Mar 2017 18:30:07 -0600 Subject: [PATCH 2/2] Updating package script to use changed Composer commands. --- tasks/package.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tasks/package.js b/tasks/package.js index d56ce90c..36c2e3aa 100644 --- a/tasks/package.js +++ b/tasks/package.js @@ -49,7 +49,7 @@ module.exports = function(grunt) { // Remove the original file if we moved it. grunt.file.delete(destPath + '/composer.json'); // Change working directory for later `composer install`. - grunt.config(['composer'], { + grunt.config(['composer', 'install'], { options: { flags: ['no-dev'], cwd: destComposer @@ -106,15 +106,15 @@ module.exports = function(grunt) { return pattern.startsWith('composer'); })) { tasks.push('packageRewriteComposer'); - grunt.config(['composer'], { + grunt.config(['composer', 'install'], { options: { flags: ['no-dev'], cwd: destPath } }); - tasks.push('composer:install'); + tasks.push('composer:install:install'); grunt.config(['composer', 'drupal-scaffold'], {}); - tasks.push('composer:drupal-scaffold'); + tasks.push('composer:drupal-scaffold:drupal-scaffold'); } if (this.args[0] && this.args[0] === 'compress') {