Babel no funciona en git hook

Quiero sincronizar algunos files de proyecto después de presionar en el server. Por lo tanto, uso un gancho post-receive que llama a la siguiente línea

 /usr/bin/gulp babel --branch $branch --path $i 

donde $ branch es devel y $ i es server/server.js

Este es mi file gulp:

 var gulp = require('gulp'), gprint = require('gulp-print'), notify = require('gulp-notify'), babel = require('gulp-babel'), gWatch = require('gulp-watch'); var argv = require('yargs').argv; gulp.task('default', ['watch-js', 'watch-all']); // run with gulp babel --branch devel --path server/server.js gulp.task('babel', function() { console.log('argv path: ',argv.path); console.log('argv branch: ',argv.branch); if (argv.path.indexOf('server/') == 0) { return gulp.src(argv.path, { base: './' }) .pipe(babel()) .pipe(gulp.dest('../wikaike-'+argv.branch+'-deployed')) .pipe(gprint(function(filePath){ return "File processed: " + filePath; })); } else { return; } }); 

Si ejecuto el command de esta manera obtengo esta salida:

 [18:35:11] Using gulpfile /var/www/wikaike-devel/gulpfile.js [18:35:11] Starting 'babel'... argv path: server/server.js argv branch: devel [18:35:15] File processed: ../wikaike-devel-deployed/server/server.js [18:35:15] Finished 'babel' after 4.36 s 

pero si presiono, obtengo este:

 remote: [18:47:20] Using gulpfile /var/www/wikaike-devel/gulpfile.js remote: [18:47:20] Starting 'babel'... remote: argv path: server/server.js remote: argv branch: devel remote: abort: 0           $0        remote: remote: ==== Stack trace ============================================ remote: remote: Security context: 0x3733462d <JS Object>#0# remote: 1: /* anonymous */ [/var/www/wikaike-devel/node_modules/is-utf8/is-utf8.js:~2] (this=0x373346d5 <JS Global Object>#1#,bytes=0x57528e71 <a Buffer>#2#) remote: 2: /* anonymous */(aka /* anonymous */) [/var/www/wikaike-devel/node_modules/vinyl-fs/node_modules/strip-bom/index.js:9] (this=0x37308091 <undefined>,arg=0x57528e71 <a Buffer>#2#) remote: 3: /* anonymous */(aka /* anonymous */) [/var/www/wikaike-devel/node_modules/vinyl-fs/lib/src/getContents/bufferFile.js:11] (this=0x37308091 <undefined>,err=0x37308081 <null>,data=0x57528e71 <a Buffer>#2#) remote: 4: /* anonymous */ [fs.js:266] (this=0x373346d5 <JS Global Object>#1#,er=0x37308081 <null>) remote: 5: /* anonymous */ [/var/www/wikaike-devel/node_modules/vinyl-fs/node_modules/graceful-fs/graceful-fs.js:102] (this=0x373346d5 <JS Global Object>#1#,er=0x37308081 <null>) remote: 7: oncomplete [fs.js:107] (this=0x575292e9 <an Object>#3#) remote: 8: arguments adaptor frame: 1->0 remote: remote: ==== Details ================================================ remote: remote: [1]: /* anonymous */ [/var/www/wikaike-devel/node_modules/is-utf8/is-utf8.js:~2] (this=0x373346d5 <JS Global Object>#1#,bytes=0x57528e71 <a Buffer>#2#) { remote: // stack-allocated locals remote: var i = 11629 remote: // expression stack (top to bottom) remote: [02] : 0 remote: [01] : 2019638 remote: --------- sourcecode --------- remote: function (bytes)?{? var i = 0;? while(i < bytes.length)? {? if( (// ASCII? bytes[i] == 0x09 ||? bytes[i] == 0x0A ||? bytes[i] == 0x0D ||? (0x20 <= bytes[i] && bytes[i] <= 0x7E)? )? ) {? ... remote: remote: ----------------------------------------- remote: } remote: remote: [2]: /* anonymous */(aka /* anonymous */) [/var/www/wikaike-devel/node_modules/vinyl-fs/node_modules/strip-bom/index.js:9] (this=0x37308091 <undefined>,arg=0x57528e71 <a Buffer>#2#) { remote: // expression stack (top to bottom) remote: [02] : 0x57528e71 <a Buffer>#2# remote: [01] : 0x373346d5 <JS Global Object>#1# remote: [00] : 0x44fecad1 <JS Function>#4# remote: --------- sourcecode --------- remote: function (arg) {??if (typeof arg === 'string') {???return arg.replace(/^\ufeff/g, '');??}???if (Buffer.isBuffer(arg) && isUtf8(arg) &&???arg[0] === 0xef && arg[1] === 0xbb && arg[2] === 0xbf) {???return arg.slice(3);??}???return arg;?} remote: ----------------------------------------- remote: } remote: remote: [3]: /* anonymous */(aka /* anonymous */) [/var/www/wikaike-devel/node_modules/vinyl-fs/lib/src/getContents/bufferFile.js:11] (this=0x37308091 <undefined>,err=0x37308081 <null>,data=0x57528e71 <a Buffer>#2#) { remote: // expression stack (top to bottom) remote: [03] : 0x57528e71 <a Buffer>#2# remote: [02] : 0x37308091 <undefined> remote: [01] : 0x44fecaf5 <JS Function>#5# remote: [00] : 0x57524f79 <a File>#6# remote: --------- sourcecode --------- remote: function (err, data) {? if (err) {? return cb(err);? }? file.contents = stripBom(data);? cb(null, file);? } remote: ----------------------------------------- remote: } remote: remote: [4]: /* anonymous */ [fs.js:266] (this=0x373346d5 <JS Global Object>#1#,er=0x37308081 <null>) { remote: // expression stack (top to bottom) remote: [03] : 0x57528e71 <a Buffer>#2# remote: [02] : 0x37308081 <null> remote: [01] : 0x37308091 <undefined> remote: [00] : 0x57527ca9 <JS Function>#7# remote: --------- sourcecode --------- remote: function (er) {? if (size === 0) {? // collected the data into the buffers list.? buffer = Buffer.concat(buffers, pos);? } else if (pos < size) {? buffer = buffer.slice(0, pos);? }?? if (encoding) buffer = buffer.toString(encoding);? return callback(er, buffer);?... remote: remote: ----------------------------------------- remote: } remote: remote: [5]: /* anonymous */ [/var/www/wikaike-devel/node_modules/vinyl-fs/node_modules/graceful-fs/graceful-fs.js:102] (this=0x373346d5 <JS Global Object>#1#,er=0x37308081 <null>) { remote: // expression stack (top to bottom) remote: [02] : 0x37308081 <null> remote: [01] : 0x373346d5 <JS Global Object>#1# remote: [00] : 0x57529081 <JS Function>#8# remote: --------- sourcecode --------- remote: function (er) {? onclose()? cb(er)? } remote: ---------------/var/opt/gitlab/git-data/repositories/root/wikaike.git/hooks/deploy-hook: line 42: 26701 Bus error /usr/bin/gulp babel --branch $branch --path $i 

Para abreviar: Babel no funciona si empiezo a usar mi gancho post-recepción. Pero la secuencia de commands funciona en el server (comenzó con el usuario git)

¿Alguna idea de lo que está pasando?

Los dos elementos para verificar (cuando un command funciona en la línea de command pero no como un gancho Git) son:

  • el usuario que ejecuta la secuencia de commands
  • las variables de entorno (más notablemente el $PATH )

Si $PATH difiere, algunas herramientas pueden faltar o tener una versión diferente a la esperada.

    Intereting Posts