These changes are primarily aiming for having an acceptable developer
experience when working on changes locally and want to run the test
suite.
By using `esm` as a required package to be executed *before* the
individual test files are executed, `esm` allows CommonJS/`require()`
based code to use code written with ES Modules syntax.
In practise that means our existing CommonJS based test suite that is
`require()`ing the source code witten in ES Modules, is seamless and
totally transparent. It just works without any build or transpiling
pipeline like `babel` involved.
Caveat: the `esm` package only support Node.js 6.x and above.
That is more than okey, as we've got continous integration to verify
how our changes works on different versions of Node.js, browsers & deno.
Refs https://www.npmjs.com/package/esm
In an effort of ensuring consistent code style in test files as with
the "production" source code, we should run eslint as part of the
`$ npm test` script as well.
Most of the related fixes was done by `eslint` using the `--fix` argument.
Only special configuration tweaks for tests compared to the other
source code, is to allow functions declaration without names. The
rationale for allowing that in tests, is that the important reason we
have them in the source code (proper stacktraces) aren't as important
in test files.
Fixes this failure:
1) Mustache CLI without partials writes rendered template into the file specified by the third argument:
Uncaught TypeError [ERR_INVALID_CALLBACK]: Callback must be a function
at makeCallback (fs.js:136:11)
at Object.unlink (fs.js:943:14)
at test/cli-test.js:86:12
at ChildProcess.exithandler (child_process.js:285:7)
at maybeClose (internal/child_process.js:982:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)
Signed-off-by: Anders Kaseorg <andersk@mit.edu>
* Fixes CLI tests for windows
* Hijacked exec so we don't have to wrap each command in changeForOS, and made replacing 'cat' safer with word boundaries
* Fixing changed tests to be more consistent with the code base
CLI used to render a mustache template with a data view, writes the template into stdout when successfull. Otherwise meaningfull errors into stderr.
Fixes#424