asciidoctor / asciidoctor-cli.js

The Command Line Interface (CLI) for Asciidoctor.js
https://asciidoctor.org
MIT License
15 stars 9 forks source link

Lazily loaded modules broke the require option for reveal.js #35

Closed obilodeau closed 5 years ago

obilodeau commented 5 years ago

Due to the change we introduced in https://github.com/asciidoctor/asciidoctor-reveal.js/issues/219, fixing issue https://github.com/asciidoctor/asciidoctor-reveal.js/issues/205.

stacktrace:

$ ./node_modules/asciidoctor-cli/bin/asciidoctorjs -r asciidoctor-reveal.js -b revealjs -a revealjsdir=node_modules/reveal.js@ presentation.adoc
internal/modules/cjs/loader.js:637
    throw new ERR_INVALID_ARG_TYPE('id', 'string', id);
    ^

TypeError [ERR_INVALID_ARG_TYPE]: The "id" argument must be of type string. Received type object
    at Module.require (internal/modules/cjs/loader.js:637:11)
    at require (internal/modules/cjs/helpers.js:22:18)
    at convertOptions (/home/olivier/src/asciidoc/test-npm/node_modules/asciidoctor-cli/lib/cli.js:35:5)
    at Object.run (/home/olivier/src/asciidoc/test-npm/node_modules/asciidoctor-cli/lib/cli.js:185:19)
    at Object.<anonymous> (/home/olivier/src/asciidoc/test-npm/node_modules/asciidoctor-cli/bin/asciidoctorjs:8:5)
    at Module._compile (internal/modules/cjs/loader.js:707:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:718:10)
    at Module.load (internal/modules/cjs/loader.js:605:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:544:12)
    at Function.Module._load (internal/modules/cjs/loader.js:536:3)

This code is unreleased and the breaking behavior will be advertized in asciidoctor-reveal.js'. I just wanted to plug how to use asciidoctor-cli.js in the docs but stumbled upon the issue when testing.

No rush, I can always document using asciidoctorjs cli later. It's nice btw. Since reveal.js is in Javascript, it simplifies deployment greatly. I'll probably start promoting this instead of the ruby back-end to colleagues.

ggrossetie commented 5 years ago

That's a good point, thanks! I think the CLI should check if the required library is an object and if this object has a register function. If it's the case then we should call the register function before doing the conversion.