jerrysu / gulp-rsync

Gulp plugin for deploying files via rsync
119 stars 51 forks source link

gulp-rsync crashes when it's output is redirected to a file #9

Closed dankeder closed 8 years ago

dankeder commented 9 years ago

gulp-rsync crashes when it's output is redirected to a file:

$ gulp build > xxx    
/home/user/project/node_modules/gulp-rsync/log.js:8
  process.stdout.cursorTo(0);
                 ^
TypeError: Object #<SyncWriteStream> has no method 'cursorTo'
    at Console.log (/home/user/project/node_modules/gulp-rsync/log.js:8:18)
    at module.exports (/home/user/project/node_modules/gulp-util/lib/log.js:8:15)
    at module.exports (/home/user/project/node_modules/gulp-rsync/log.js:15:26)
    at /home/user/project/node_modules/gulp-rsync/index.js:112:13
    at Array.forEach (native)
    at /home/user/project/node_modules/gulp-rsync/index.js:111:29
    at Array.forEach (native)
    at Socket.handler (/home/user/project/node_modules/gulp-rsync/index.js:110:37)
    at Socket.EventEmitter.emit (events.js:95:17)
    at Socket.<anonymous> (_stream_readable.js:745:14)

I believe it should never ever call process.stdout.cursorTo(0). Removing that line helps, as well as adding silent: true to arguments.

nlundquist commented 9 years ago

This also causes crashes when gulp is run from within an IDE that is piping the output from stdout. I agree this should be removed.

NicolasSiver commented 9 years ago

Seems project is abandoned ;)

alansouzati commented 9 years ago

Yeah it does seems abandoned. If you add option silent it skips the issue. I know it is not the proper fix, but at least I was able to get around this issue.

rsync({
  ...
  silent: true,
  ...
});
im-kulikov commented 8 years ago

This is fix the problem

 process.stdout.write(util.format.apply(this, arguments) + "\r\r");
'use strict';

var gutil = require('gulp-util');
var util = require('util');

function log() {
    process.stdout.write(util.format.apply(this, arguments) + "\r\r");

}

module.exports = function() {
    // HACK: In order to show rsync's transfer progress, override `console` temporarily...
    var orig = console.log;
    console.log = log;
    var retval = gutil.log.apply(this, arguments);
    console.log = orig;
    return retval;
};
kdimatteo commented 8 years ago

thanks @alansouzati, this worked