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

Fix: fix prompt-installation #572 #589

Closed
wants to merge 1 commit into from
Closed

Conversation

duzy
Copy link

@duzy duzy commented Sep 15, 2018

the strange things in this fix is about packages -- if it's not indicating the sub-command or a list of commands?

What kind of change does this PR introduce?

Did you add tests for your changes?

If relevant, did you update the documentation?

Summary

Does this PR introduce a breaking change?

Other information
Fixes #572

the strange things in this fix is about packages -- if it's not indicating the sub-command or a list of commands?
@jsf-clabot
Copy link

jsf-clabot commented Sep 15, 2018

CLA assistant check
All committers have signed the CLA.

@webpack-bot
Copy link

@duzy The most important CI builds failed. This way your PR can't be merged.

Please take a look at the CI results from travis (failure) and fix these issues.

@evenstensberg evenstensberg changed the title An attempt to fix #572 Fix: fix prompt-installation #572 Sep 15, 2018
Copy link
Member

@evenstensberg evenstensberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Mind filling in the issue template with a better description? :

@@ -105,6 +105,10 @@ module.exports = function promptForInstallation(packages, ...args) {
}
});
} else {
require(pathForCmd).default(...args); // eslint-disable-line
let p = require(pathForCmd), c = p[packages];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you try to make this a bit prettier with better variable names?

Copy link
Author

@duzy duzy Sep 15, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ev1stensberg Hi Even, you might try refining the name as wish, I'd like to present this patch for discussion as I'm NOT quite certain about packages -- as the name literally suggested, it might have multiple package names? The other possible fix might be changing the @webpack-cli/xxx modules, e.g.

function serve() {
    blah(...)
    blah(...)
}

export abc;
export xyz;
export default serve;

as webpack-cli seems to expect any @webpack-cli/xxx to offer a default export as a function, which is rational. But webpack-cli deserves a type check.

// pseudo
let module = required(pathForCmd), func = module.default;
if (typeof func !== 'function') throw new exception('opps, @webpack-cli/'+packages+' not meeting the spec');
func(...args);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes in theory the package that we want to load should export a default function and I think bombing an error is fine, in order to dictate a standard. Your pseudo solution looks fine

@evenstensberg
Copy link
Member

Can you produce a PR that contains full naming conventions and try to make it so that the tests pass?

Copy link
Member

@evenstensberg evenstensberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @duzy, how's it going? Do you need help?

@duzy
Copy link
Author

duzy commented Nov 15, 2018

Hi @evenstensberg , I'm working on other non-js projects. Just can't follow up in time. But yes, my JS project is using this patch and working so far. I will keep following up this thread.

@evenstensberg
Copy link
Member

No worries

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

Successfully merging this pull request may close these issues.

bug: require(...).default is not a function
5 participants