Closed Kristories closed 10 years ago
What exactly is the problem?
Is there a way to handle errors when dependencies
is empty?
Why should I use this plugin when I have no dependencies? ;)
:beers:
I'll give a good reason: Because I'm writing a package where users can optionally specify bower dependencies. It would be understandable that the error testing logic would by my responsibility if the docs weren't worded this way:
This will read your bower.json, iterate through your dependencies and build a gulp.src() with all files defined in the main property of the packages bower.json
This implies that the gulp.src()
will be empty if there are no dependencies, not that node will crash. The proper behaviour here would be to simply do nothing or emit a non-blocking warning. If two people were willing to report a bug, imagine how many other people may be affected?
Please give this some consideration. Thanks! :heart_eyes_cat:
Hi, I have this same problem. How can I fix this??
This scenario should be handled, not just because because implementing it is an obvious test-case that the plugin fails to handle gracefully ("positive glob missing"? is that the best error message you can emit? \ really? **).
For our specific purpose this plugin is deployed as part of a gulp project that is scaffolded by slush.
Depending on selection of options and case, the resulting project MAY NOT HAVE bower components included initially. However, the gulp project should transparently merge bower files into the built application without requiring the developer to modify the build files.
Until this plugin can handle the case of no active dependencies and pass though $.util.noop() it's not really complete, and doesn't report its' failure in a clear way.
This error is thrown in gulp (glob-stream), not in gulp-bower-files.
It would be the same if you try:
gulp.task('nonsense_task', function() {
return gulp.src([]).pipe(gulp.dest('.'));
});
Generic CoffeeScript workaround, allows you to use the plugin in the cases where
buildBower:()->
hasBower = fs.existsSync './bower_components'
if not hasBower then console.log "YOU DO NOT HAVE ANY BOWER COMPONENTS IN USE"
return true if not hasBower
bowerconfig=JSON.parse fs.readFileSync './bower.json',encoding:'utf8'
return true if Object.keys(bowerconfig.dependencies).length==0
doYourBowerStuffNow()
My issue is that the plugin is smart enough to find and parse the bower config, but just isn't clever enough to return something more informative than the upstream error. It doesn't take a lot more checking as my example shows.
The question is: Why should I create a gulp task, which does something with bower packages, but I have no bower packages (yet)?
Any scenario where you are building a system (example: slush/yo generator) where the initial project may or may not have default bower packages based on user configuration.
The fragility of your plugin reduces its' usefulness.
In 0.2.4 the plugin returns an empty stream, see: 5e670410669ae8d838a9041ce6513a0a4cb6b0dc
Looks promising, will test as soon as I get a moment! Thanks for update.
Bower task
Watching
bower.json
Uninstall all packages and get an error when dependencies is empty