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
Give a warning if two components have the same handle/url #188
Comments
@Risker I think some sort of warning in the CLI when fractal comes across two duplicate handles is definitely a good idea to have and should be pretty easy to add in. In the meantime, and similar to my answer to #189 if you want to do a 'check' on all your components to see if any have any duplicate handles you could use a custom command like the following: fractal.cli.command('check-handles', function(opts, done){
fractal.load().then(src => {
const used = [];
let error = false;
for (let comp of fractal.components.flatten()) {
const handle = comp.handle;
const previous = used.filter(u => u.handle === handle);
if (previous.length) {
error = true;
let paths = previous.map(p => p.path);
paths.push(comp.viewPath);
this.console.error(`Duplicate handle @${handle} - used in
- ${paths.join('\n - ')}
`);
}
used.push({
handle: handle,
path: comp.viewPath
});
}
if (!error) {
this.console.success('No duplicate handles found!');
}
});
done();
}); Add that into your fractal.js file and then you should be able to run it using |
This is a bit awesome :) |
I'm going to close this issue now - @Risker if you have any probs with the above feel free to re-open. |
This is a problem with a large system. I have come across two separate issues:
Both of these result in the same handle and url.
I can (sort-of) fix these issues by specifying a prefix in a collection/component config, but first I would need to now where I'm having an overwrite issue without manually going through my component tree.
The second possible solution would be to automatically prefix certain collections with the collection name (eg if I have nested collections I should only set
prefix: true
on the first level collection) and all duplicate url issues for that collection are solved.The text was updated successfully, but these errors were encountered: