1
我想在推送服務器之後給一些項目文件添加巴別克。 所以我用一個post-receive
鉤子調用下面一行Babel不能在git hook中工作
/usr/bin/gulp babel --branch $branch --path $i
其中$分公司是devel
和$ i是server/server.js
這是我一飲而盡文件:
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;
}
});
如果我運行命令這種方式我得到這個輸出:
[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
但如果我推我得到這個:
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: --------- s o u r c e c o d e ---------
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: --------- s o u r c e c o d e ---------
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: --------- s o u r c e c o d e ---------
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: --------- s o u r c e c o d e ---------
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: --------- s o u r c e c o d e ---------
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
要長話短說:如果用我的後收到鉤開始巴貝爾是行不通的。但腳本在服務器上運行(用git用戶啓動)
任何想法發生了什麼?
你可以讓你的post-receive腳本顯示腳本被推動觸發時使用的用戶和pwd(當前工作路徑)嗎? – VonC
已經這樣做了,它和正常情況一樣(正確的) – Wikunia
也許'$ PATH'是不同的? – VonC