lukeed / taskr

A fast, concurrency-focused task automation tool.
MIT License
2.53k stars 74 forks source link

Cleanup argument handling behaviors #191

Closed lukeed closed 8 years ago

lukeed commented 8 years ago

With #189 (thanks to @tjbenton!), fly.source, fly.clear, fly.start, and fly.watch had their APIs modified and/or refactored to allow for option objects to parsed from glob-arrays.

Despite passing tests, his first pass was unusable at runtime / outside of the test environment. (Add "better tests" to the todo list...)

This fills in the gaps while still maintaining the new features.

Changes:


Thanks to @hzlmn for pointing out the issue & jumpstarting the process.

tjbenton commented 8 years ago

What was the issue with rest arguments? I was actually working on adding more test cases for this while I was working on another feature.

tjbenton commented 8 years ago

I think I see why there was a problem, it comes from this commit. He updated the isPlainObject function to actually be correct because I had !== instead of === like it should have been. But when he made that change he didn't update the places where it was called to be !isPlainObject(options)

if (!isPlainObject(options)) {
    globs.push(options)
    options = {}
}

In the pr I'm working on I added 6+ tests cases fly.source and similar tests for the other functions that were touched.

lukeed commented 8 years ago

@tjbenton I did that as well, still had issues. 😟 I also checked out your PR commit directly.

It's okay though, I prefer this method of handling arguments. It's less code, more intuitive, and more consistent. Only fly.clear has the flexible sourcing (because it's one argument).