gulpjs / gulp-cli

Command Line Interface for gulp.
MIT License
401 stars 106 forks source link

error: unknown option '--tasks' #199

Closed y3g0r closed 5 years ago

y3g0r commented 5 years ago

Problem

Running gulp with flag (except for --version, --help) w/o specifying a task returns error: unknown option '<flag>', e.g.:

➜  client git:(master) gulp --tasks
error: unknown option '--tasks'
➜  client git:(master) gulp --tasks blabla
error: unknown option '--tasks'
➜  client git:(master) gulp blabla --tasks
[14:31:11] Tasks for ~/work/hypotes.is/client/gulpfile.js
[14:31:11] ├── build-vendor-js
[14:31:11] ├─┬ build-js
...
➜  client git:(master) gulp --no-color    
error: unknown option '--no-color'
➜  client git:(master) gulp whatever --no-color
[14:32:29] Using gulpfile ~/work/hypotes.is/client/gulpfile.js
[14:32:29] Task never defined: whatever
[14:32:29] To list available tasks, try running: gulp --tasks

Expected behavior

Running gulp with options from gulp --help should produce documented result. task command line option shouldn't be always required.

Steps to reproduce

I'm including project so that you can check if something is wrong with its gulpfile.js.

Environment

OS:

➜  ~ lsb_release -d
Description:    Ubuntu 18.04.2 LTS

Node, npm & npx:

➜  client git:(master) node --version
v12.13.0
➜  client git:(master) npm --version
6.12.0
➜  client git:(master) npx --version
6.12.0

Gulp & gulp-cli:

➜  client git:(master) gulp --version
CLI version: 2.2.0
Local version: 4.0.2

Project:

➜  client git:(master) git remote -v
origin  https://github.com/hypothesis/client.git (fetch)
origin  https://github.com/hypothesis/client.git (push)
➜  client git:(master) git describe --always
v1.123.0-1097-g380f6de3
➜  client git:(master) git status
On branch master
Your branch is up to date with 'origin/master'.

nothing to commit, working tree clean
➜  client git:(master) cat package.json | grep gulp
    "gulp": "^4.0.0",
    "gulp-changed": "^4.0.0",
    "gulp-if": "^3.0.0",
    "gulp-postcss": "^8.0.0",
    "gulp-rename": "^1.2.2",
    "gulp-replace": "^1.0.0",
    "gulp-sourcemaps": "^2.6.4",
    "gulp-util": "^3.0.7",
    "build": "cross-env NODE_ENV=production gulp build",
    "test": "gulp test",
➜  client git:(master) head gulpfile.js 
/* eslint-env node */

'use strict';

const { mkdirSync } = require('fs');
const path = require('path');

const changed = require('gulp-changed');
const commander = require('commander');
const debounce = require('lodash.debounce');

P.S. I might be doing something stupidly wrong, I'm new to JS ecosystem, so don't get too mad.

y3g0r commented 5 years ago

88 related

y3g0r commented 5 years ago

Workaround: feed in some dummy task placeholder, like so:

$ gulp gulp --tasks
sttk commented 5 years ago

@y3g0r I reproduced by following the above steps, and I found that the 'unknown option' error was output by not gulp-cli but commandar in the gulpfile.js. Please review the usage of commander.

y3g0r commented 5 years ago

Thanks a lot for looking into it. I'll report the problem with commander to hypothesis maintainers.