Skip to content

Commit

Permalink
Merge tag '0.6.1'
Browse files Browse the repository at this point in the history
LogTape 0.6.1
  • Loading branch information
dahlia committed Sep 24, 2024
2 parents 8e033a3 + 09d3441 commit 6c08fe7
Show file tree
Hide file tree
Showing 8 changed files with 61 additions and 6 deletions.
7 changes: 6 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
{
"deno.enable": true,
"deno.unstable": true,
"deno.unstable": [
"fs"
],
"editor.detectIndentation": false,
"editor.indentSize": 2,
"editor.insertSpaces": true,
"files.eol": "\n",
"files.insertFinalNewline": true,
"files.trimFinalNewlines": true,
Expand Down
18 changes: 18 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ Version 0.7.0
To be released.


Version 0.6.1
-------------

Released on September 24, 2024.

- Fixed a build error due to importing `node:fs` module on [Vite]. [[#18]]


Version 0.6.0
-------------

Expand Down Expand Up @@ -42,6 +50,16 @@ Released on September 24, 2024.
[#17]: https://github.com/dahlia/logtape/issues/17


Version 0.5.3
-------------

Released on September 24, 2024.

- Fixed a build error due to importing `node:fs` module on [Vite]. [[#18]]

[#18]: https://github.com/dahlia/logtape/issues/18


Version 0.5.2
-------------

Expand Down
11 changes: 9 additions & 2 deletions deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,15 @@
"consolemock": "npm:consolemock@^1.1.0",
"which_runtime": "https://deno.land/x/[email protected]/mod.ts"
},
"exclude": ["*-venv/", "coverage/", "docs/", "npm/"],
"unstable": ["fs"],
"exclude": [
"*-venv/",
"coverage/",
"docs/",
"npm/"
],
"unstable": [
"fs"
],
"lock": false,
"tasks": {
"check": "deno check **/*.ts && deno lint && deno fmt --check",
Expand Down
6 changes: 6 additions & 0 deletions dnt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ await build({
);
await Deno.copyFile("logtape/fs.cjs", "npm/esm/fs.cjs");
await Deno.copyFile("logtape/fs.cjs", "npm/script/fs.js");
await Deno.writeTextFile(
"npm/esm/nodeUtil.js",
'import util from "./nodeUtil.cjs";\nexport default util;\n',
);
await Deno.copyFile("logtape/nodeUtil.cjs", "npm/esm/nodeUtil.cjs");
await Deno.copyFile("logtape/nodeUtil.cjs", "npm/script/nodeUtil.js");
await Deno.copyFile("LICENSE", "npm/LICENSE");
await Deno.copyFile("README.md", "npm/README.md");
},
Expand Down
4 changes: 2 additions & 2 deletions logtape/formatter.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import util from "node:util";
import type { LogLevel } from "./level.ts";
import util from "./nodeUtil.ts";
import type { LogRecord } from "./record.ts";

/**
Expand Down Expand Up @@ -44,7 +44,7 @@ const inspect: (value: unknown, options?: { colors?: boolean }) => string =
? globalThis.Deno.inspect.bind(globalThis.Deno)
// @ts-ignore: Node.js global
// dnt-shim-ignore
: "inspect" in util && typeof util.inspect === "function"
: util != null && "inspect" in util && typeof util.inspect === "function"
// @ts-ignore: Node.js global
// dnt-shim-ignore
? util.inspect.bind(util)
Expand Down
2 changes: 1 addition & 1 deletion logtape/fs.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ if (
"Bun" in globalThis
) {
try {
fs = require("node" + ":fs");
fs = require(["node", "fs"].join(":"));
} catch (_) {
fs = null;
}
Expand Down
16 changes: 16 additions & 0 deletions logtape/nodeUtil.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
let util = null;
if (
"process" in globalThis && "versions" in globalThis.process &&
"node" in globalThis.process.versions &&
typeof globalThis.caches === "undefined" &&
typeof globalThis.addEventListener !== "function" ||
"Bun" in globalThis
) {
try {
util = require(["node", "util"].join(":"));
} catch (_) {
util = null;
}
}

module.exports = util;
3 changes: 3 additions & 0 deletions logtape/nodeUtil.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import util from "node:util";

export default util;

0 comments on commit 6c08fe7

Please sign in to comment.