使用gulp exec运行bash脚本

时间:2015-10-16 14:18:00

标签: bash gulp

我正在尝试使用gulp exec运行bul脚本,其中gulp可以更新项目中的资产。脚本的目录如下:

./assets/update_assets.sh

我已经按照文档和我的gulpfile看了如下:

'use-strict';

var gulp  = require('gulp'),
    gutil = require('gulp-util');
    exec    = require('child_process').exec;

gulp.task('update-assets', function (cb) {
    exec('./assets/update_assets.sh', function(err, stdout, stderr) {
        console.log(stdout);
        console.log(stderr);
        cb(err);
    });
});

gulp.task('default', ['update-assets'], function() {
    gulp.start('update-assets');
});

当我尝试运行gulp时,我得到错误:

 [15:13:47] Error: Command failed: /bin/sh -c ./assets/update_assets.sh
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   168  100   168    0     0    197      0 --:--:-- --:--:-- --:--:--   197
tar: Unrecognized archive format
tar: Error exit delayed from previous errors.
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   168  100   168    0     0    288      0 --:--:-- --:--:-- --:--:--   288
tar: could not chdir to 'README.md/'

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   168  100   168    0     0    265      0 --:--:-- --:--:-- --:--:--   264
tar: Unrecognized archive format
tar: Error exit delayed from previous errors.
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   168  100   168    0     0    276      0 --:--:-- --:--:-- --:--:--   276
tar: could not chdir to 'gulpfile.js/'

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   168  100   168    0     0    283      0 --:--:-- --:--:-- --:--:--   282
tar: Unrecognized archive format
tar: Error exit delayed from previous errors.
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   168  100   168    0     0    268      0 --:--:-- --:--:-- --:--:--   268
tar: could not chdir to 'package.json/'


    at ChildProcess.exithandler (child_process.js:744:12)
    at ChildProcess.emit (events.js:110:17)
    at maybeClose (child_process.js:1008:16)
    at Socket.<anonymous> (child_process.js:1176:11)
    at Socket.emit (events.js:107:17)
    at Pipe.close (net.js:476:12)

0 个答案:

没有答案