Skip to content

Commit 414c8f7

Browse files
committed
chore: esm only
1 parent 4d1f4b5 commit 414c8f7

8 files changed

+48
-45
lines changed

bin/cli.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
"use strict";
22

3-
const pump = require("pump");
4-
const split = require("split2");
3+
import pump from "pump";
4+
import split from "split2";
55

6-
const { getTransformStream } = require("..");
6+
import { getTransformStream } from "../index.js";
77

88
const options = {
99
logFormat: process.env.LOG_FORMAT,

index.d.ts

+10-15
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,15 @@
11
import { Transform } from "node:stream";
22

3-
type getTransformStream = (options?: getTransformStream.Options) => Transform;
3+
type getTransformStream = (options?: Options) => Transform;
44

5-
declare namespace getTransformStream {
6-
export type LogLevel = "trace" | "debug" | "info" | "warn" | "error" | "fatal";
5+
export type LogLevel = "trace" | "debug" | "info" | "warn" | "error" | "fatal";
76

8-
export type Options = {
9-
logFormat?: "json" | "pretty";
10-
logLevelInString?: boolean;
11-
sentryDsn?: string;
12-
};
7+
export type Options = {
8+
logFormat?: "json" | "pretty";
9+
logLevelInString?: boolean;
10+
sentryDsn?: string;
11+
};
1312

14-
export const getTransformStream: getTransformStream
15-
export { getTransformStream as default }
16-
}
17-
18-
declare function getTransformStream(...params: Parameters<getTransformStream>): ReturnType<getTransformStream>
19-
20-
export = getTransformStream
13+
export {
14+
getTransformStream
15+
}

index.js

+4-8
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
"use strict";
22

3-
const { Transform } = require("node:stream");
3+
import { Transform } from "node:stream";
44

5-
const { prettyFactory } = require("pino-pretty");
6-
const { init, withScope, captureException } = require("@sentry/node");
5+
import { prettyFactory } from "pino-pretty";
6+
import { init, withScope, captureException } from "@sentry/node";
77

88
const LEVEL_MAP = {
99
10: "trace",
@@ -40,7 +40,7 @@ const pinoErrorProps = [
4040
* @returns Transform
4141
* @see https://getpino.io/#/docs/transports
4242
*/
43-
function getTransformStream(options = {}) {
43+
export function getTransformStream(options = {}) {
4444
const formattingEnabled = options.logFormat !== "json";
4545

4646
const levelAsString = options.logLevelInString;
@@ -161,7 +161,3 @@ function toSentryError(data) {
161161
error.stack = data.stack;
162162
return error;
163163
}
164-
165-
module.exports = getTransformStream;
166-
module.exports.default = getTransformStream;
167-
module.exports.getTransformStream = getTransformStream;

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"pino-probot": "./bin/cli.js"
1010
},
1111
"description": "formats pino logs and sends errors to Sentry",
12+
"type": "module",
1213
"main": "index.js",
1314
"types": "index.d.ts",
1415
"scripts": {

test/cli.test.js

+10-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
"use strict";
22

3-
const { join: pathJoin } = require("node:path");
4-
const { spawn } = require("node:child_process");
5-
const { test } = require("tap");
3+
import {
4+
dirname as pathDirname,
5+
join as pathJoin,
6+
resolve as pathResolve,
7+
} from "node:path";
8+
import { spawn } from "node:child_process";
9+
import { test } from "tap";
10+
import { fileURLToPath } from "node:url";
611

7-
const cliPath = require.resolve(pathJoin(__dirname, "..", "bin", "cli.js"));
12+
const __dirname = pathDirname(fileURLToPath(import.meta.url));
13+
const cliPath = pathResolve(pathJoin(__dirname, "..", "bin", "cli.js"));
814
const nodeBinaryPath = process.argv[0];
915

1016
const logLine =

test/index.test.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
"use strict";
22

3-
const { Writable: WritableStream } = require("stream");
3+
import { Writable as WritableStream } from "stream";
44

5-
const { test } = require("tap");
6-
const { pino } = require("pino");
7-
const { getTransformStream } = require("..");
5+
import { test } from "tap";
6+
import { pino } from "pino";
7+
import { getTransformStream } from "../index.js";
88

99
test("API", (t) => {
1010
let env = Object.assign({}, process.env);

test/sentry.cli.test.js

+12-7
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
11
"use strict";
22

3-
const { join: pathJoin } = require("node:path");
4-
const { spawn } = require("node:child_process");
5-
const { createServer } = require("node:http");
6-
const { test } = require("tap");
7-
const { once } = require("node:events");
3+
import {
4+
dirname as pathDirname,
5+
join as pathJoin,
6+
resolve as pathResolve,
7+
} from "node:path";
8+
import { spawn } from "node:child_process";
9+
import { createServer } from "node:http";
10+
import { test } from "tap";
11+
import { once } from "node:events";
12+
import { fileURLToPath } from "node:url";
813

914
const SENTRY_DSN = "http://[email protected]/1234";
10-
11-
const cliPath = require.resolve(pathJoin(__dirname, "..", "bin", "cli.js"));
15+
const __dirname = pathDirname(fileURLToPath(import.meta.url));
16+
const cliPath = pathResolve(pathJoin(__dirname, "..", "bin", "cli.js"));
1217
const nodeBinaryPath = process.argv[0];
1318

1419
const errorLine =

test/sentry.runtime.test.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
"use strict";
22

3-
const { withScope } = require("@sentry/node");
3+
import { withScope } from "@sentry/node";
44

5-
const { test } = require("tap");
6-
const { pino } = require("pino");
7-
const { getTransformStream } = require("..");
5+
import { test } from "tap";
6+
import { pino } from "pino";
7+
import { getTransformStream } from "../index.js";
88

99
test("API", (t) => {
1010
t.plan(1);

0 commit comments

Comments
 (0)