I would to know how I can run a drush command like drush @alias cc all
with a gulp workflow ?
This is my starting code:
var plugins = require('gulp-load-plugins')();
gulp.task('drush:cc', function () {
return gulp.src(source)
.pipe(plugins.shell([
'drush @vmdevd6mg cc all'
]))
.pipe(plugins.notify({
title: "Caches cleared",
message: "Drush Drupal CSS/JS caches cleared.",
onLast: true
}));
});
Thanks EDIt: another way to run drush but seem not to work too,no error message given.
// Run drush to clear the theme registry.
gulp.task('drush', plugins.shell.task([
'drush @vmdevd6mg cc all'
]));
both tasks give:
gulp drush
Error: spawn drush @vmdevd6mg cc all ENOENT
EDIT1: New test
My new task and the result:
//Vidage de cache Drupal avec Drush
gulp.task('drush', function() {
return gulp.src(basePaths.drushscript, {
read: false
})
.pipe(plugins.shell([
'drush @vmdevd6pf cron && drush @vmdevd6pf cc all'
]))
.pipe(plugins.notify({
title: "Vidage de Cache",
message: "Cache Drupal vidé complètement.",
onLast: true
}));
});
Part of the global launch task:
gulp.watch(folderPaths.js.jsd68, ['drush']);
Give:
/bin/sh: 1: drush: Permission denied
events.js:160
throw er; // Unhandled 'error' event
^
Error: Command `drush @vmdevd6pf cron && drush @vmdevd6pf cc all` failed with exit code 127
EDIT: final gulp task work like //Vidage de cache Drupal avec child_process - 2020-06
gulp.task('drush-cp', function(done) {
return cp.spawn('drush', ['cache-rebuild'], {stdio: 'inherit'})
.on('close', done)
/* .pipe(plugins.notify({
title: "Vidage de Cache avec Drush",
message: "Cache Drupal vidé complètement.",
onLast: true
})); */
;
});