create-playwright-pom-start 1.0.13 → 1.0.15
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/README.md +1 -0
- package/index.js +28 -0
- package/package.json +1 -1
package/README.md
CHANGED
package/index.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
+
import fs from "fs";
|
|
4
|
+
import path from "path";
|
|
3
5
|
import { spawnSync } from "child_process";
|
|
4
6
|
import { createRequire } from "module";
|
|
5
7
|
|
|
@@ -8,4 +10,30 @@ const binPath = require.resolve("playwright-pom/bin/index.js");
|
|
|
8
10
|
const result = spawnSync(process.execPath, [binPath, ...process.argv.slice(2)], {
|
|
9
11
|
stdio: "inherit",
|
|
10
12
|
});
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
const pkgPath = path.join(process.cwd(), "package.json");
|
|
16
|
+
if (fs.existsSync(pkgPath)) {
|
|
17
|
+
try {
|
|
18
|
+
const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf-8"));
|
|
19
|
+
let changed = false;
|
|
20
|
+
|
|
21
|
+
if (pkg.main !== "index.js") {
|
|
22
|
+
pkg.main = "index.js";
|
|
23
|
+
changed = true;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
if (!pkg.type || pkg.type !== "module") {
|
|
27
|
+
pkg.type = "module";
|
|
28
|
+
changed = true;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (changed) {
|
|
32
|
+
fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + "\n", "utf-8");
|
|
33
|
+
}
|
|
34
|
+
} catch {
|
|
35
|
+
// ignore parse errors
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
11
39
|
process.exit(result.status ?? 1);
|