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

--help tosses exception #43

Closed
boneskull opened this issue Jul 28, 2016 · 4 comments
Closed

--help tosses exception #43

boneskull opened this issue Jul 28, 2016 · 4 comments

Comments

@boneskull
Copy link
Contributor

reproduce

$ npm install [email protected]
# snip
$ node_modules/.bin/package-scripts --help


  Usage: package-scripts [options]

  Options:

    -h, --help                                  output usage information
    -V, --version                               output the version number
    -s, --silent                                Silent p-s output
    -p, --parallel <script-name1,script-name2>  Scripts to run in parallel (comma seprated)
    -c, --config <filepath>                     Config file to use (defaults to nearest package-scripts.js)
    -l, --log-level <level>                     The log level to use (error, warn, info [default])
    -r, --require <module>                      Module to preload

/Volumes/alien/mochajs/mocha-core/node_modules/p-s/dist/bin-utils/index.js:117
  return moduleName[0] === '.' ? (0, _path.resolve)(process.cwd(), moduleName) : moduleName;
                   ^

TypeError: Cannot read property '0' of null
    at getModuleRequirePath (/Volumes/alien/mochajs/mocha-core/node_modules/p-s/dist/bin-utils/index.js:117:20)
    at attemptModuleRequire (/Volumes/alien/mochajs/mocha-core/node_modules/p-s/dist/bin-utils/index.js:122:23)
    at getPSConfig (/Volumes/alien/mochajs/mocha-core/node_modules/p-s/dist/bin/p-s.js:72:41)
    at Command.onHelp (/Volumes/alien/mochajs/mocha-core/node_modules/p-s/dist/bin/p-s.js:93:32)
    at emitNone (events.js:86:13)
    at Command.emit (events.js:185:7)
    at Command.outputHelp (/Volumes/alien/mochajs/mocha-core/node_modules/commander/index.js:1024:8)
    at outputHelpIfNecessary (/Volumes/alien/mochajs/mocha-core/node_modules/commander/index.js:1078:11)
    at Command.parseArgs (/Volumes/alien/mochajs/mocha-core/node_modules/commander/index.js:620:5)
    at Command.parse (/Volumes/alien/mochajs/mocha-core/node_modules/commander/index.js:458:21)
@boneskull
Copy link
Contributor Author

Actually ..huh. I can't run p-s from p-s.

@boneskull
Copy link
Contributor Author

OK, so if I remove my custom --config .package-scripts.js, it works fine.

@boneskull
Copy link
Contributor Author

(The --help is still a problem, however.)

@kentcdodds
Copy link
Collaborator

I was able to reproduce this. The problem is that p-s is unable to find your package-scripts.js file. Here's a minimal example of it working:

npm install [email protected]
echo "module.exports = {scripts: {}}" > package-scripts.js
node_modules/.bin/package-scripts --help

If you want a custom config:

npm install [email protected]
echo "module.exports = {scripts: {}}" > .p-s.js
node_modules/.bin/package-scripts --help --config ./.p-s.js

I think though that we should probably fix the underlying issue. Would you be interested in making a pull request? The code in question starts here

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

2 participants