Skip to content
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
4 changes: 0 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

permissions:
actions: write
contents: read

jobs:
lint:
name: ⬣ Lint
Expand Down
144 changes: 68 additions & 76 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 3 additions & 18 deletions src/capture-errors.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,7 @@ describe('captureErrors function', () => {
const cause = await effectCause(task);

const result = await Effect.runPromise(
pipe(
captureErrors(cause, {
stripCwd: false,
}),
Effect.provide(NodeFileSystem.layer),
),
pipe(captureErrors(cause, false), Effect.provide(NodeFileSystem.layer)),
);

expect(result.interrupted).toBe(false);
Expand Down Expand Up @@ -60,12 +55,7 @@ describe('captureErrors function', () => {
const cause = await effectCause(task);

const result = await Effect.runPromise(
pipe(
captureErrors(cause, {
stripCwd: false,
}),
Effect.provide(NodeFileSystem.layer),
),
pipe(captureErrors(cause, false), Effect.provide(NodeFileSystem.layer)),
);

expect(result.interrupted).toBe(false);
Expand All @@ -80,12 +70,7 @@ describe('captureErrors function', () => {
const cause = await effectCause(Effect.interrupt);

const result = await Effect.runPromise(
pipe(
captureErrors(cause, {
stripCwd: false,
}),
Effect.provide(NodeFileSystem.layer),
),
pipe(captureErrors(cause, false), Effect.provide(NodeFileSystem.layer)),
);

expect(result).toStrictEqual({
Expand Down
13 changes: 5 additions & 8 deletions src/capture-errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,9 @@ export interface CapturedErrors {
errors: ErrorData[];
}

export interface CaptureErrorsOptions {
stripCwd?: boolean;
}

export const captureErrors = <E>(
cause: Cause<E>,
options: CaptureErrorsOptions = {
stripCwd: true,
},
stripCwd?: boolean,
): Effect.Effect<
CapturedErrors,
PlatformError | JsonParsingError,
Expand All @@ -50,7 +44,10 @@ export const captureErrors = <E>(
}

const rawErrors = captureErrorsFrom<E>(cause);
const errors = yield* Effect.forEach(rawErrors, transformRawError(options));
const errors = yield* Effect.forEach(
rawErrors,
transformRawError(stripCwd),
);

return {
interrupted: false,
Expand Down
2 changes: 1 addition & 1 deletion src/examples/without-spans.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ describe('without-spans task', () => {
expect(raw).not.toContain('Sources 🕵️');
expect(raw).toContain('Node Stacktrace 🚨');
expect(message).toMatch(
/│ at catcher (.*\/effect-errors\/src\/examples\/without-spans.ts:14:17)/,
/│ at catcher (.*\/src\/examples\/without-spans.ts:14:17)/,
);
});
});
Expand Down
4 changes: 3 additions & 1 deletion src/logic/path/strip-cwd-path.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
const cwdRegex =
global.process !== undefined ? new RegExp(global.process.cwd(), 'g') : null;
globalThis.process === undefined
? null
: new RegExp(globalThis.process.cwd(), 'g');

export const stripCwdPath = (path: string): string =>
cwdRegex === null ? path : path.replace(cwdRegex, '.');
Loading