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
Allow reading bundle from stdin #269
Conversation
it('reads from stdin', async () => { | ||
let result; | ||
try { | ||
const cp = execa('../../index.js', ['--driver', 'puppeteer', '-'], { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alternatively we could also teach run
about this behaviot, dunno if it's worth it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That'd make it rather complicated, no?
} | ||
|
||
async function mergeWithDefault(default_config_promise, config) { | ||
const default_config = await default_config_promise; | ||
if (default_config) { | ||
return deepmerge(default_config.config, config); | ||
return deepmerge(default_config.config, config, { | ||
clone: false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cloning a stream apparently causes infinite recursion. Don't think not cloning will hurt us here.
@@ -6,6 +6,10 @@ const glob = promisify(require('glob')); | |||
exports.resolveSpec = resolveSpec; | |||
|
|||
async function resolveSpec(spec = 'test/**/*.js') { | |||
if (typeof spec === 'object' && typeof spec.pipe === 'function') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found it nicer to handle such situations at lib
level instead of index.js
as index.js already contains a lot of control flow and it would have gotten even more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I also get the feeling it's growing quite a bit.
Maybe it's time to introduce more functions like run
that handle parts of the control flow. E.g. configure
, launch
, run
and shutdown
. Just a random morning thought though 🙃
|
||
exports.validateConfig = validateConfig; | ||
|
||
function validateConfig(config) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left this function intentionally simple (i.e. manual checking) for now. We can start building our declarative mini DSL later ...
const { exit_code } = await mochify(opts); | ||
} | ||
delete opts._; | ||
mochify(opts) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unwrapping this and using a Promise chain is here to stop eslint from complaining. I'm not entirely sure if its complaints are correct or not yet. We could also keep the old version and ignore the rule, no real preference from my side here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably even easier to read than the self-invoking async function. 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks very good to me. Thank you. Just a minor stylistic question, but feel free to merge.
mochify ./src/*.test.js # Let the shell handle glob expansion | ||
mochify "./src/*.test.js" # Let Mochify handle glob expansion |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
const { exit_code } = await mochify(opts); | ||
} | ||
delete opts._; | ||
mochify(opts) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably even easier to read than the self-invoking async function. 👍
mochify/index.js
Outdated
const validation_error = validateConfig(config); | ||
if (validation_error) { | ||
throw validation_error; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is validateConfig
not throwing the errors directly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like I've just been writing too much Go lately. I'll change this as it makes sense for this to behave like everything else (which is throwing to stop execution).
Solves #268