Skip to content

Instantly share code, notes, and snippets.

@rlouapre
Last active August 29, 2015 14:20
Show Gist options
  • Save rlouapre/f4d1e257dda43364995f to your computer and use it in GitHub Desktop.
Save rlouapre/f4d1e257dda43364995f to your computer and use it in GitHub Desktop.
Watch src and load and MarkLogic using Roxy
var gulp = require('gulp');
var gutil = require('gulp-util')
var watch = require('gulp-watch');
var plumber = require('gulp-plumber');
var shell = require('gulp-shell')
var roxy = {
'cwd': 'roxy',
'env': 'local',
'db' : {
'modules': 'ci-ml-modules'
}
};
gulp.task('xqy:watch', function() {
watch(['src/**/*.xqy'], {read: false})
.pipe(plumber()) // This will keeps pipes working after error event - It should be removed in gupljs 4.0
.pipe(
shell(
[
'ml ' + roxy.env + ' load <%= normalize(file.path) %> --db=' + roxy.db.modules + ' --remove-prefix=<%= normalize(join(file)) %> -v'
],
{
'cwd': roxy.cwd,
'templateData': {
'normalize': function(s) {
s = s.replace(/\\/g,'/');
if (s.substring(s.length-1) === '/') {
s = s.substring(0, s.length-1)
}
return s;
},
'join': function(f) {
return path.join(f.cwd, f.base);
}
}
}
)
);
});
{
"name": "xqy-watch",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"devDependencies": {
"gulp": "^3.8.11",
"gulp-plumber": "^1.0.0",
"gulp-shell": "^0.4.1",
"gulp-util": "^3.0.4",
"gulp-watch": "^4.2.4"
}
}
@rlouapre
Copy link
Author

Assumptions:
Roxy in ./roxy
Source file in ./src
Update roxy object in glupfile.js

Run:
npm install
gulp xqy:watch

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