dthree / cash

Cross-platform Linux commands in ES6
MIT License
7.77k stars 199 forks source link

Invalid export from package.json #27

Closed knksmith57 closed 8 years ago

knksmith57 commented 8 years ago

Programmatic access is stone cold busted.

This is the result of a bad main reference to ./lib/index.js in package.json: https://github.com/dthree/cash/blob/master/package.json#L5. I'm guessing we want ./dist/index.js instead since that file exists

Example of bad things happening:

❯ npm install cash
cash@0.2.2 node_modules/cash
├── array-shuffle@1.0.0
├── filesize@3.2.1
├── minimist@1.2.0
├── vorpal-less@0.0.13 (slice-ansi@0.0.3)
├── user-home@2.0.0 (os-homedir@1.0.1)
├── vorpal-autocomplete-fs@0.0.3 (strip-ansi@3.0.1)
├── chalk@1.1.1 (escape-string-regexp@1.0.5, supports-color@2.0.0, strip-ansi@3.0.1, has-ansi@2.0.0, ansi-styles@2.2.0)
├── fkill@3.1.0 (taskkill@1.0.0, arrify@1.0.1, pify@2.3.0, pinkie-promise@2.0.0)
├── glob@6.0.4 (path-is-absolute@1.0.0, inherits@2.0.1, once@1.3.3, inflight@1.0.4, minimatch@3.0.0)
├── vorpal-grep@0.1.2 (glob@5.0.15)
├── fs-extra@0.23.1 (path-is-absolute@1.0.0, jsonfile@2.2.3, graceful-fs@4.1.3, rimraf@2.5.2)
├── username@1.0.1 (meow@3.7.0)
├── lodash@4.5.1
└── vorpal@1.9.5 (mindash@4.5.0, node-localstorage@0.6.0, strip-ansi@3.0.1, log-update@1.0.2, inquirer@0.11.0, babel-polyfill@6.5.0, babel-runtime@6.5.0)

❯ node -e 'var $ = require("cash");'
module.js:327
    throw err;
    ^

Error: Cannot find module 'cash'
    at Function.Module._resolveFilename (module.js:325:15)
    at Function.Module._load (module.js:276:25)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
    at [eval]:1:9
    at Object.exports.runInThisContext (vm.js:54:17)
    at Object.<anonymous> ([eval]-wrapper:6:22)
    at Module._compile (module.js:409:26)
    at node.js:574:27
    at nextTickCallbackWith0Args (node.js:415:9)

❯ node -e 'console.log(require("./node_modules/cash/package.json").main)'
./lib/index.js

I'll work up a PR real quick.

dthree commented 8 years ago

Holy snap! How did I miss that? You're totally correct.

Thanks for doing the PR.


All of my programmatic tests were from within the full environment with src included, so I never actually required cash as a dependency!

knksmith57 commented 8 years ago

Haha, I've actually done this exact same thing before! At least it's an easy fix ;)

Also added a test case to try and catch this going forward.

Cheers!