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

Crash when trying to install a package using gittio as a module #118

Open
AndreaVitale opened this issue Oct 25, 2016 · 2 comments
Open

Comments

@AndreaVitale
Copy link

I'm trying to install a package using gittio as a commonjs module but the install method causes this error:

[ERROR] dk.napp.social:commonjs no distributable availableevelLifecycles Finishing
/usr/local/lib/node_modules/custom-cli/node_modules/gittio/lib/dist.js:29
      if (memo && available[scope] && available[scope][platform] && available[scope][platform][cmp.id]) {
                           ^

TypeError: Cannot read property 'undefined' of undefined
    at /usr/local/lib/node_modules/custom-cli/node_modules/gittio/lib/dist.js:29:28
    at Array.reduce (native)
    at Function._.reduce._.foldl._.inject (/usr/local/lib/node_modules/custom-cli/node_modules/gittio/node_modules/underscore/underscore.js:113:28)
    at Object.exports.isInstalled (/usr/local/lib/node_modules/custom-cli/node_modules/gittio/lib/dist.js:18:14)
    at /usr/local/lib/node_modules/custom-cli/node_modules/gittio/lib/gittio.js:322:26
    at Array.forEach (native)
    at Function._.each._.forEach (/usr/local/lib/node_modules/custom-cli/node_modules/gittio/node_modules/underscore/underscore.js:79:11)
    at component.lookup.action (/usr/local/lib/node_modules/custom-cli/node_modules/gittio/lib/gittio.js:320:7)
    at Request._callback (/usr/local/lib/node_modules/custom-cli/node_modules/gittio/lib/component.js:40:7)
    at Request.self.callback (/usr/local/lib/node_modules/custom-cli/node_modules/gittio/node_modules/request/request.js:186:22)
Andreas-MacBook-Pro:magneto Andrea$ 
@FokkeZB
Copy link
Contributor

FokkeZB commented Oct 25, 2016

Who wrote this crap?! 😉

https://github.com/FokkeZB/gittio/blob/master/bin/gittio.js uses https://github.com/FokkeZB/gittio/blob/master/lib/gittio.js#L657-L660, which is what is exported as module API, but before it does, it calls config.init() which sets the scope that is undefined in your error. And after that it also sneaks in argsToParams() to further translate the input arg to params to pass to the method.

This needs some serious refactoring and separation of concerns:

  • a new index.js should export a working module API, calling config and all.
  • bin/gittio.js should use this API and only add the input to params thing.
  • lib/config.js should not be state-full but return a config object to just use for the current call.
  • Lots of clean up in all of this

I really wish I had time to do this, but I don't. Wanna help out? @dbankier maybe?

@dbankier
Copy link
Contributor

@FokkeZB, sorry, neglecting my own projects atm. No time either.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants