Skip to content

Commit 810e3a9

Browse files
authored
Merge pull request #294 from phase2/conditionally-run-drupal-scaffold
Conditionally run composer:drupal-scaffold.
2 parents 778e22c + 1a07459 commit 810e3a9

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

bootstrap.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,10 @@ module.exports = function(grunt) {
6060
tasksDefault.push('scaffold');
6161

6262
if (grunt.file.exists('./composer.lock') && grunt.config.get(['composer', 'install'])) {
63-
// Manually run `composer drupal-scaffold` since this is only automatically run on update.
64-
tasksDefault.unshift('composer:drupal-scaffold');
63+
if (grunt.task.exists('composer:drupal-scaffold')) {
64+
// Manually run `composer drupal-scaffold` since this is only automatically run on update.
65+
tasksDefault.unshift('composer:drupal-scaffold');
66+
}
6567
// Run `composer install` if there is already a lock file. Updates should be explicit once this file exists.
6668
tasksDefault.unshift('composer:install');
6769
} else if (grunt.config.get(['composer', 'update'])) {

tasks/composer.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ module.exports = function(grunt) {
55
* Dynamically adds a Composer install task if a composer.json file
66
* exists in the project directory.
77
*/
8-
98
if (require('fs').existsSync('./composer.json')) {
109
grunt.loadNpmTasks('grunt-composer');
1110
var Help = require('../lib/help')(grunt);
@@ -28,7 +27,12 @@ module.exports = function(grunt) {
2827
]
2928
}
3029
});
31-
grunt.config(['composer', 'drupal-scaffold'], {});
30+
31+
// Add the drupal-scaffold task if it is defined in the `composer.json`.
32+
var composer = require('fs').readFileSync('./composer.json', 'utf8');
33+
if (typeof composer.scripts !== 'undefined' && 'drupal-scaffold' in composer.scripts) {
34+
grunt.config(['composer', 'drupal-scaffold'], {});
35+
}
3236

3337
Help.add({
3438
task: 'composer',

0 commit comments

Comments
 (0)