Skip to content

Instantly share code, notes, and snippets.

@alroniks
Last active April 1, 2018 14:08
Show Gist options
  • Save alroniks/1466b67a648949a1bbea to your computer and use it in GitHub Desktop.
Save alroniks/1466b67a648949a1bbea to your computer and use it in GitHub Desktop.
Gulpfile for run watch commands for Gitify (MODX)
'use strict';
console.time('Loading plugins');
var gulp = require('gulp'),
watch = require('gulp-watch'),
shell = require('gulp-shell'),
tap = require('gulp-tap');
console.timeEnd('Loading plugins');
var path = {
watch: {
modx: '_data/**/*.*'
},
modx: {
root: '.',
data: '_data/'
}
};
function modxTaskCreator(type) {
gulp.task('modx:build:' + type, function () {
gulp.src(path.modx.data + type)
.pipe(shell([
//'gitify build ' + type + ' --skip-clear-cache'
'gitify build ' + type
], {cwd: path.modx.root}));
});
}
gulp.task('modx:init', function() {
gulp.src(path.modx.data + '*')
.pipe(tap(function (file, t) {
modxTaskCreator(file.path.split('/').pop());
}));
});
gulp.start('modx:init');
gulp.task('modx:build', function() {
gulp.src(path.modx.data + '*')
.pipe(tap(function (file, t) {
gulp.start('modx:build:' + file.path.split('/').pop());
}));
});
gulp.task('watch', function(){
watch([path.watch.modx], function(event, cb) {
var path = event.path.split('/');
var type = path[path.length - 2];
gulp.start('modx:build:' + type);
});
});
gulp.task('default', ['modx:build', 'watch']);
{
"name": "sitename.com",
"version": "1.0.0",
"devDependencies": {
"gulp": "^3.8.1",
"gulp-shell": "*",
"gulp-tap": "*",
"gulp-watch": "*"
}
}
# examples ans steps for run
# For start you should copy Gulpfile.js and package.json to your MODX root directory.
# You should have installed Gitify (globbaly, should be available run gitify command from CLI, see documentation of Gitify)
# 1. Install nodejs and npm (here https://nodejs.org/)
# 2. Install gulp with dependencies
npm install
# 3. Run gulp tasks for build and watch
gulp
@sergo-8ck
Copy link

При запуске gulp все проходит успешно, стоит изменить какой-либо файл шаблона в _data/templates выходит ошибка
Task 'modx:build:undefined' is not in your gulpfile. В чем причина?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment