Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

request support: -h/--help arguments #73

Closed
ghost opened this issue Nov 22, 2015 · 18 comments
Closed

request support: -h/--help arguments #73

ghost opened this issue Nov 22, 2015 · 18 comments

Comments

@ghost
Copy link

ghost commented Nov 22, 2015

returns https://github.com/depcheck/depcheck#usage

get arguments always need to look at the document you want to support the more convenient

@lijunle
Copy link
Member

lijunle commented Nov 22, 2015

The --help argument is there. Does it work?

--help: Show the help message.

@ghost
Copy link
Author

ghost commented Nov 23, 2015

develop@develop-vm ~/Projects/project (master*) $ depcheck --help

Unused devDependencies
* babel-eslint
* eslint-config-react
* eslint-plugin-react
develop@develop-vm ~/Projects/project (master*) $ 

@lijunle
Copy link
Member

lijunle commented Nov 23, 2015

Weird, which OS are you using?

It works fine on my Windows and Ubuntu environment.


Ubuntu:

lijunle@depcheck:~/workspace/tmp $ cat /etc/issue
Ubuntu 14.04.2 LTS \n \l

lijunle@depcheck:~/workspace/tmp $ ./node_modules/.bin/depcheck --help
Usage: node_modules/.bin/depcheck [DIRECTORY]

Options:
  --dev                 Check on devDependecies        [boolean] [default: true]
  --ignore-bin-package  Ignore package with bin entry [boolean] [default: false]
  --json                Output results to JSON
  --ignores             Comma separated package list to ignore
  --ignore-dirs         Comma separated folder names to ignore
  --parsers             Comma separated glob:pasers pair list
  --detectors           Comma separated detector list
  --specials            Comma separated special parser list
  --help                Show this help message

Windows:

C:\Projects\tmp>.\node_modules\.bin\depcheck --help
Usage: C:\Program Files\iojs\node.exe C:\Projects\tmp\node_modules\depcheck\bin\depcheck [DIRECTORY]

Options:
  --dev                 Check on devDependecies        [boolean] [default: true]
  --ignore-bin-package  Ignore package with bin entry [boolean] [default: false]
  --json                Output results to JSON
  --ignores             Comma separated package list to ignore
  --ignore-dirs         Comma separated folder names to ignore
  --parsers             Comma separated glob:pasers pair list
  --detectors           Comma separated detector list
  --specials            Comma separated special parser list
  --help                Show this help message

@ghost
Copy link
Author

ghost commented Nov 23, 2015

develop@develop-vm ~/Projects/project (master*) $ cat /etc/issue
Ubuntu 14.04.3 LTS \n \l

develop@develop-vm ~/Projects/project (master*) $ where depcheck
/usr/local/bin/depcheck
/usr/bin/depcheck
develop@develop-vm ~/Projects/project (master*) $ 

@ghost
Copy link
Author

ghost commented Nov 23, 2015

develop@develop-vm ~/Projects/project (master*) $ /usr/local/bin/depcheck --help

Unused devDependencies
* babel-eslint
* eslint-config-react
* eslint-plugin-react
develop@develop-vm ~/Projects/project (master*) $ /usr/bin/depcheck --help      
Usage: depcheck [DIRECTORY]

Options:
  --dev                 Check on devDependecies        [boolean] [default: true]
  --ignore-bin-package  Ignore package with bin entry [boolean] [default: false]
  --json                Output results to JSON
  --ignores             Comma separated package list to ignore
  --ignore-dirs         Comma separated folder names to ignore
  --parsers             Comma separated glob:pasers pair list
  --detectors           Comma separated detector list
  --specials            Comma separated special parser list
  --help                Show this help message

develop@develop-vm ~/Projects/project (master*) $ diff /usr/bin/depcheck /usr/local/bin/depcheck 
3c3,8
< /* eslint-disable no-console */
---
> var optimist = require('optimist')
>   .usage('Usage: $0 [DIRECTORY]')
>   .boolean('dev')
>   .default('dev', true)
>   .describe('no-dev', 'Don\'t look at devDependecies')
>   .describe('json', 'Output results to JSON');
5,9c10,62
< require('../dist/cli')(
<   process.argv.slice(2),
<   console.log,
<   console.error,
<   process.exit);
---
> var argv = optimist.argv;
> 
> var checkDirectory = require('../index');
> var fs = require('fs');
> var path = require('path');
> var dir = argv._[0] || '.';
> var absolutePath = path.resolve(dir);
> 
> fs.exists(absolutePath, function (pathExists) {
>   if (pathExists) {
>     fs.exists(absolutePath + path.sep + 'package.json', function (exists) {
>       if (exists) {
>         run();
>       } else {
>         console.error('Path ' + dir + ' does not contain a package.json file');
>         optimist.showHelp();
>         process.exit(-1);
>       }
>     });
>   } else {
>     console.error('Path ' + dir + ' does not exist');
>     process.exit(-1);
>   }
> });
> 
> function run() {
>   checkDirectory(absolutePath, { "withoutDev": !argv.dev }, function (unused) {
>     if (argv.json) {
>       console.log(JSON.stringify(unused));
>       return process.exit(0);
>     }
> 
>     if (unused.dependencies.length === 0 && unused.devDependencies.length === 0) {
>       console.log('No unused dependencies');
>       process.exit(0);
>     } else {
>       if (unused.dependencies.length !== 0) {
>         console.log('Unused Dependencies');
>         unused.dependencies.forEach(function (u) {
>           console.log('* ' + u);
>         });
>       }
>       if (unused.devDependencies.length !== 0) {
>         console.log();
>         console.log('Unused devDependencies');
>         unused.devDependencies.forEach(function (u) {
>           console.log('* ' + u);
>         });
>       }
>       process.exit(-1);
>     }
>   });
> }

@ghost
Copy link
Author

ghost commented Nov 23, 2015

perhaps because I've used I n the reason caused.
thx.

remove /usr/local/bin/depcheck after normal

@lijunle
Copy link
Member

lijunle commented Nov 23, 2015

From the npm document, it should be installed to /usr/local folder. I have no idea about how n handle this.

Besides, version 0.5.10 should handle the eslint related packages. Enjoy it. 😃

@ghost
Copy link
Author

ghost commented Nov 23, 2015

thx

@ghost ghost closed this as completed Nov 23, 2015
@ghost
Copy link
Author

ghost commented Nov 23, 2015

develop@develop-vm ~/Projects/project (master*) $ depcheck 

Unused devDependencies
* eslint
develop@develop-vm ~/Projects/project (master*) $ 

@lijunle
Copy link
Member

lijunle commented Nov 23, 2015

OK, how could you run your eslint command? Is it in your package.json or .travis.yml?

@ghost
Copy link
Author

ghost commented Nov 23, 2015

.eslintrc file
see http://eslint.org/docs/user-guide/configuring.html

@lijunle
Copy link
Member

lijunle commented Nov 23, 2015

Do you install eslint as a global package or a local one?

@ghost
Copy link
Author

ghost commented Nov 23, 2015

{
....
  "devDependencies": {
    ....
    "eslint": "^1.9.0",
    ....
  }
.....
}

I think "eslint" is "devDependencies"

@lijunle
Copy link
Member

lijunle commented Nov 23, 2015

OK.

Do you run eslint by manually running ./node_modules/eslint . command, or add it to scripts section in package.json, or somewhere else?

@ghost
Copy link
Author

ghost commented Nov 23, 2015

yep

@lijunle
Copy link
Member

lijunle commented Nov 23, 2015

You mean, you run by manually input the ./node_modules/eslint . command?

In that case, I think that is a useless dev dependency for your package, because you could install it globally.

However, another option is to integrate the eslint command to package.json file, or your CI configuration file. Then, it will be considered as a useful dependency.

@ghost
Copy link
Author

ghost commented Nov 23, 2015

Yep, understand
If you meet this condition eslint proposal to include warning?

@lijunle
Copy link
Member

lijunle commented Nov 23, 2015

What's the meaning of "jslint proposal to include warning"?

gtanner pushed a commit to gtanner/depcheck that referenced this issue Jan 19, 2016
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant