@arghajit/dummy 0.3.5 → 0.3.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@arghajit/dummy",
3
3
  "author": "Arghajit Singha",
4
- "version": "0.3.5",
4
+ "version": "0.3.6",
5
5
  "description": "A Playwright reporter and dashboard for visualizing test results.",
6
6
  "homepage": "https://playwright-pulse-report.netlify.app/",
7
7
  "keywords": [
@@ -2,6 +2,7 @@
2
2
  import * as fs from "fs";
3
3
  import * as path from "path";
4
4
  import { pathToFileURL } from "url";
5
+ import { dirname } from "path";
5
6
 
6
7
  const DEFAULT_OUTPUT_DIR = "pulse-report";
7
8
 
@@ -26,31 +27,51 @@ async function extractOutputDirFromConfig(configPath) {
26
27
  try {
27
28
  let config;
28
29
 
29
- if (configPath.endsWith(".ts")) {
30
- try {
31
- const { register } = await import("node:module");
32
- const { pathToFileURL } = await import("node:url");
30
+ const configDir = dirname(configPath);
31
+ const originalDirname = global.__dirname;
32
+ const originalFilename = global.__filename;
33
33
 
34
- register("ts-node/esm", pathToFileURL("./"));
34
+ try {
35
+ global.__dirname = configDir;
36
+ global.__filename = configPath;
35
37
 
36
- config = await import(pathToFileURL(configPath).href);
37
- } catch (tsError) {
38
+ if (configPath.endsWith(".ts")) {
38
39
  try {
39
- const tsNode = await import("ts-node");
40
- tsNode.register({
41
- transpileOnly: true,
42
- compilerOptions: {
43
- module: "ESNext",
44
- },
45
- });
40
+ const { register } = await import("node:module");
41
+ const { pathToFileURL } = await import("node:url");
42
+
43
+ register("ts-node/esm", pathToFileURL("./"));
44
+
46
45
  config = await import(pathToFileURL(configPath).href);
47
- } catch (fallbackError) {
48
- console.error("Failed to load TypeScript config:", fallbackError);
49
- return null;
46
+ } catch (tsError) {
47
+ try {
48
+ const tsNode = await import("ts-node");
49
+ tsNode.register({
50
+ transpileOnly: true,
51
+ compilerOptions: {
52
+ module: "ESNext",
53
+ },
54
+ });
55
+ config = await import(pathToFileURL(configPath).href);
56
+ } catch (fallbackError) {
57
+ console.error("Failed to load TypeScript config:", fallbackError);
58
+ return null;
59
+ }
50
60
  }
61
+ } else {
62
+ config = await import(pathToFileURL(configPath).href);
63
+ }
64
+ } finally {
65
+ if (originalDirname !== undefined) {
66
+ global.__dirname = originalDirname;
67
+ } else {
68
+ delete global.__dirname;
69
+ }
70
+ if (originalFilename !== undefined) {
71
+ global.__filename = originalFilename;
72
+ } else {
73
+ delete global.__filename;
51
74
  }
52
- } else {
53
- config = await import(pathToFileURL(configPath).href);
54
75
  }
55
76
 
56
77
  const playwrightConfig = config.default || config;