fix(embed, normalize): an output in a folder that does not exist is refused by name (#290)
Closes #290.
An output named in a folder that does not exist is now refused by name, before any work.
h5p-embed --scorm(buildScorm): it ended in an uncaughtENOENTwith a stack trace, after the whole zip had been planned. It now exits 1 withNo such folder: <folder>. Create it, or name a zip in a folder that exists.h5p-normalize -o(normalizeArchive): it exited witherror: h5p.json: ENOENT …, blaming an entry. It now names the folder, before the source is opened.
h5p-author build and bundle already refused such an output, and h5p-embed <folder> and h5p-author read create their folder; those are unchanged.
Tested
packages/embed/tests/scorm.test.ts: 38 of 38, with the new case (refused as anEmbedError, and the folder is not created).packages/normalize/tests/normalize.test.ts: 12 of 12, with the new case.- Both commands run by hand against a missing folder print the message and exit 1.
Patch releases of h5p-embed and h5p-normalize when the next release goes out.
Summary by cubic
h5p-embed --scorm and h5p-normalize -o now refuse an output whose folder does not exist or is a file, before any work starts.
Previously, h5p-embed --scorm crashed with an uncaught ENOENT stack trace after planning the whole zip, and h5p-normalize blamed an entry for a mid-write failure. Both now exit 1 with No such folder: <folder>. or <folder> is a file, not a folder.
h5p-author build and bundle already refused such outputs, and h5p-embed <folder> and h5p-author read create the folder, so those are unchanged. The fix ships in the next patch releases of h5p-embed and h5p-normalize.