Skip to content

Instantly share code, notes, and snippets.

@mikaa123
Created May 22, 2014 07:45

Revisions

  1. mikaa123 created this gist May 22, 2014.
    37 changes: 37 additions & 0 deletions gulpfile.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,37 @@
    var gulp = require('gulp'),
    gutil = require('gulp-util'),
    spawn = require('child_process').spawn,
    livereload = require('gulp-livereload')
    replace = require('gulp-replace');

    gulp.task('staticsvr', function(next) {
    var staticS = require('node-static'),
    server = new staticS.Server('./'),
    port = 2888;
    require('http').createServer(function (request, response) {
    request.addListener('end', function () {
    server.serve(request, response);
    }).resume();
    }).listen(port, function() {
    gutil.log('Server listening on port: ' + gutil.colors.magenta(port));
    next();
    });
    });

    gulp.task('watch', ['staticsvr'], function() {
    var server = livereload();
    gulp.watch(['*.js', '*.css', '*.xml', '*.xsl']).on('change', function(file) {
    var child = spawn("xslty", ["input.xml adminViewSupervisorTracking.xsl > result.html"], {cwd: process.cwd()});

    child.on('close', function () {
    gutil.log('done transforming xml');
    server.changed(file.path);
    });
    });
    });

    gulp.task('build', function(){
    gulp.src(['adminViewSupervisorTracking.xsl'])
    .pipe(replace(/http\:\/\/192.168.10.57:8080/g, ''))
    .pipe(gulp.dest('build'));
    });