Skip to content

Commit

Permalink
Allow logger to work in browser (#1620)
Browse files Browse the repository at this point in the history
  • Loading branch information
forgetso authored Jan 17, 2025
1 parent cdf657a commit 421efdb
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion demos/client-bundle-example/src/frictionless.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<title>Procaptcha demo: Live Test</title>
<script type="module">
async function captchaLoaded() {
const render = (await import('./assets/procaptcha.bundle')).render
const render = (await import('./assets/procaptcha.bundle.js')).render
console.log('Captcha loaded')
// Get the Element using elementId
const captchaContainer = document.getElementById('procaptcha-container')
Expand Down
2 changes: 1 addition & 1 deletion demos/client-bundle-example/src/urlParams.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<title>Procaptcha demo: Live Test</title>
<script type="module">
async function captchaLoaded() {
const render = (await import('./assets/procaptcha.bundle')).render
const render = (await import('./assets/procaptcha.bundle.js')).render
console.log('Captcha loaded')
// Get the Element using elementId
const captchaContainer = document.getElementById('procaptcha-container')
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export default (
return {
command: "version",
describe: "Return the version of the software",
handler: async () => {
handler: () => {
logger.info(`Version: ${JSON.stringify(version)}`);
},
};
Expand Down
11 changes: 9 additions & 2 deletions packages/common/src/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,17 @@ const JSONReporter = (
options: ConsolaOptions;
},
) => {
// https://stackoverflow.com/a/65886224
const writer = process?.stdout
? process.stdout.write.bind(process.stdout)
: console.info;
const writerError = process?.stderr
? process.stderr.write.bind(process.stderr)
: console.error;
if (context.options.level === ConsolaLogLevels.error) {
process.stderr.write(`${JSON.stringify(message)}\n`);
writerError(`${JSON.stringify(message)}\n`);
} else {
process.stdout.write(`${JSON.stringify(message)}\n`);
writer(`${JSON.stringify(message)}\n`);
}
};

Expand Down

0 comments on commit 421efdb

Please sign in to comment.