Skip to content
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

Fix bug allowing logtape to work under Node.js #4

Merged
merged 4 commits into from
Jul 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ jobs:
- uses: denoland/setup-deno@v1
with:
deno-version: v1.x
- uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- run: deno task test --coverage=.cov --junit-path=.test-report.xml
- uses: EnricoMi/publish-unit-test-result-action@v2
if: runner.os == 'Linux' && always()
Expand All @@ -43,6 +46,9 @@ jobs:
token: ${{ secrets.CODECOV_TOKEN }}
slug: dahlia/logtape
file: .cov.lcov
- run: deno task dnt
- run: bun run ./test_runner.js
working-directory: ${{ github.workspace }}/npm/
- run: deno task check

publish:
Expand Down
6 changes: 6 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
LogTape changelog
=================

Version 0.4.1
-------------

To be released.


Version 0.4.0
-------------

Expand Down
1 change: 1 addition & 0 deletions deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"test": "deno test --allow-read --allow-write",
"coverage": "rm -rf coverage && deno task test --coverage && deno coverage --html coverage",
"dnt": "deno run -A dnt.ts",
"test-all": "deno task test && deno task dnt && cd npm/ && bun run ./test_runner.js && cd ../",
"hooks:install": "deno run --allow-read=deno.json,.git/hooks/ --allow-write=.git/hooks/ jsr:@hongminhee/deno-task-hooks",
"hooks:pre-commit": "deno task check",
"hooks:pre-push": "deno task test"
Expand Down
1 change: 1 addition & 0 deletions dnt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ await build({
entryPoints: ["./logtape/mod.ts"],
importMap: "./deno.json",
mappings: {
"./logtape/filesink.jsr.ts": "./logtape/filesink.node.ts",
"./logtape/filesink.deno.ts": "./logtape/filesink.node.ts",
},
shims: {
Expand Down
4 changes: 2 additions & 2 deletions logtape/filesink.deno.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ export const denoDriver: RotatingFileSinkDriver<Deno.FsFile> = {
closeSync(fd) {
fd.close();
},
statSync: Deno.statSync,
renameSync: Deno.renameSync,
statSync: globalThis?.Deno.statSync,
renameSync: globalThis?.Deno.renameSync,
};

/**
Expand Down
9 changes: 9 additions & 0 deletions logtape/filesink.jsr.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const filesink: Omit<typeof import("./filesink.deno.ts"), "denoDriver"> =
await ("Deno" in globalThis
? import("./filesink.deno.ts")
: import("./filesink.node.ts"));

export const getFileSink = filesink.getFileSink;
export const getRotatingFileSink = filesink.getRotatingFileSink;

// cSpell: ignore filesink
1 change: 0 additions & 1 deletion logtape/filesink.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ Deno.test("getFileSink()", () => {

Deno.test("getRotatingFileSink()", () => {
const path = Deno.makeTempFileSync();
console.debug({ path });
const sink: Sink & Disposable = getRotatingFileSink(path, {
maxSize: 150,
});
Expand Down
2 changes: 1 addition & 1 deletion logtape/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export {
type LoggerConfig,
reset,
} from "./config.ts";
export { getFileSink, getRotatingFileSink } from "./filesink.deno.ts";
export { getFileSink, getRotatingFileSink } from "./filesink.jsr.ts";
export {
type Filter,
type FilterLike,
Expand Down