-
Notifications
You must be signed in to change notification settings - Fork 245
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
feat(rosetta): transliterate loose mode #2892
Conversation
When transliterating code samples from a published package tarball, supporting files such as fixtures and literate source files may be missing (typically because they are part of the `.npmignore` file). The new `--loose` option to `jsii transliterate` allows ignoring those problems by: - Ignoring missing fixtures (the behavior is then the same as if no fixture was requested) - Falling back to the `.lit.js` file when the `.lit.ts` file cannot be found, or replacing the source with a placeholder if neither file could be found
// In loose mode, we'll fall back to the `.js` file if it exists... | ||
const jsFile = fullPath.replace(/\.ts(x?)$/, '.js$1'); | ||
if (fs.existsSync(jsFile)) { | ||
return fs.readFileSync(jsFile, { encoding: 'utf-8' }); |
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.
Maybe add a header here saying we are showing js
code because the expected file is missing?
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.
There is unfortunately no way to reliably do this... Leading comments will be ignored if they are not attached to a render-able statement, which may not even exist.
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.
Oh well, we tried
Thank you for contributing! ❤️ I will now look into making sure the PR is up-to-date, then proceed to try and merge it! |
Merging (with squash)... |
When transliterating code samples from a published package tarball,
supporting files such as fixtures and literate source files may be
missing (typically because they are part of the
.npmignore
file).The new
--loose
option tojsii transliterate
allows ignoring thoseproblems by:
fixture was requested)
.lit.js
file when the.lit.ts
file cannot befound, or replacing the source with a placeholder if neither file
could be found
This addresses the issue outlined in cdklabs/construct-hub#127
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.