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

Skips dependencies if there is no main property in the bower.json #166

Open
redbugz opened this issue Sep 9, 2017 · 0 comments
Open

Skips dependencies if there is no main property in the bower.json #166

redbugz opened this issue Sep 9, 2017 · 0 comments

Comments

@redbugz
Copy link

redbugz commented Sep 9, 2017

The main property is listed as recommended but not required by the bower.json spec, but if a dependency chooses to not list a main file, all of it's dependencies are skipped.

It is because of this code in package.js (https://github.com/ck86/main-bower-files/blob/master/lib/package.js#L46):

                if (prev && prev.main) {
                    return prev;
                }

                if (!exists(curr)) {
                    return prev;
                }

                try {
                    return JSON.parse(readFile(curr, 'utf8'));
                } catch (e) {
                    return null;
                }
            }, null);

In our particular case, it skipped the .bower.json and bower.json dependencies because prev.main was undefined for bower, and dropped to the package.json dependencies because component.json (curr) did not exist, returning the package.json dependencies, not the bower.json dependencies which is not what we wanted.

It treats the main property as required.

Should it use prev.name instead which is a required attribute, or check for prev.main or prev.dependencies since if either of those exists there is something to do at the next step of the function?

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

1 participant