我有我的gulpfile.coffee
gulp = require 'gulp'
coffeelint = require 'gulp-coffeelint'
mocha = require 'gulp-mocha'
plumber = require 'gulp-plumber'
gutil = require 'gulp-util'
watch = require 'gulp-watch'
handleError = (err) ->
console.error err.message
process.exit 1
gulp.task 'test', ->
gulp.src('test/*-test.*')
.pipe(mocha(reporter: 'spec'))
.on 'error', handleError
我需要运行gulp test --grep group1
,我找到options.grep但我不知道如何从CLI继续参数。
答案 0 :(得分:4)
已解决:使用yargs npm package
gulp = require 'gulp'
coffeelint = require 'gulp-coffeelint'
mocha = require 'gulp-mocha'
plumber = require 'gulp-plumber'
gutil = require 'gulp-util'
watch = require 'gulp-watch'
yargs = require 'yargs'
handleError = (err) ->
console.error err.message
process.exit 1
gulp.task 'test', ->
gulp.src('test/*-test.*')
.pipe(mocha(reporter: 'spec', grep: yargs.argv.grep))
.on 'error', handleError