@shibanet0/datamitsu-config 0.0.4 → 0.0.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/bin/datamitsu.js CHANGED
@@ -1,24 +1,17 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- import { spawn } from "node:child_process";
3
+ import { getExePath } from "@datamitsu/datamitsu/get-exe.js";
4
+ import { spawnSync } from "node:child_process";
4
5
  import { join } from "node:path";
5
6
 
6
- import { getBinaryFilepath } from "./utils.js";
7
-
8
- const arguments_ = process.argv.slice(2);
9
-
10
- if (!arguments_.includes("--binary-command")) {
11
- arguments_.unshift("--binary-command", "pnpm datamitsu");
7
+ const args = process.argv.slice(2);
8
+ if (!args.includes("--binary-command")) {
9
+ args.unshift("--binary-command", "pnpm datamitsu");
12
10
  }
13
11
 
14
- const child = spawn(
15
- "node",
16
- [
17
- getBinaryFilepath("@datamitsu/datamitsu/package.json", "../bin/index.js"),
18
- "--before-config",
19
- join(import.meta.dirname, "../datamitsu.config.js"),
20
- ...arguments_,
21
- ],
12
+ const result = spawnSync(
13
+ getExePath(),
14
+ ["--before-config", join(import.meta.dirname, "../datamitsu.config.js"), ...args],
22
15
  {
23
16
  env: {
24
17
  ...process.env,
@@ -28,10 +21,12 @@ const child = spawn(
28
21
  },
29
22
  );
30
23
 
31
- child.on("exit", (code, signal) => {
32
- if (signal) {
33
- process.kill(process.pid, signal);
34
- } else if (code !== 0) {
35
- process.exit(code);
36
- }
37
- });
24
+ if (result.error) {
25
+ throw result.error;
26
+ }
27
+
28
+ if (result.signal) {
29
+ process.kill(process.pid, result.signal);
30
+ } else {
31
+ process.exitCode = result.status ?? 1;
32
+ }
package/bin/tsc.js CHANGED
@@ -1,19 +1,21 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- import { spawn } from "node:child_process";
3
+ import { spawnSync } from "node:child_process";
4
4
 
5
5
  import { getBinaryFilepath } from "./utils.js";
6
6
 
7
- const args = process.argv.slice(2);
7
+ const result = spawnSync(
8
+ getBinaryFilepath("typescript/package.json", "bin/tsc"),
9
+ process.argv.slice(2),
10
+ { stdio: "inherit" },
11
+ );
8
12
 
9
- const child = spawn(getBinaryFilepath("typescript/package.json", "../bin/tsc"), args, {
10
- stdio: "inherit",
11
- });
13
+ if (result.error) {
14
+ throw result.error;
15
+ }
12
16
 
13
- child.on("exit", (code, signal) => {
14
- if (signal) {
15
- process.kill(process.pid, signal);
16
- } else if (code !== 0) {
17
- process.exit(code);
18
- }
19
- });
17
+ if (result.signal) {
18
+ process.kill(process.pid, result.signal);
19
+ } else {
20
+ process.exitCode = result.status ?? 1;
21
+ }
package/bin/tsx.js CHANGED
@@ -1,19 +1,21 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- import { spawn } from "node:child_process";
3
+ import { spawnSync } from "node:child_process";
4
4
 
5
5
  import { getBinaryFilepath } from "./utils.js";
6
6
 
7
- const args = process.argv.slice(2);
7
+ const result = spawnSync(
8
+ "node",
9
+ [getBinaryFilepath("tsx", "../dist/cli.mjs"), ...process.argv.slice(2)],
10
+ { stdio: "inherit" },
11
+ );
8
12
 
9
- const child = spawn("node", [getBinaryFilepath("tsx", "../../dist/cli.mjs"), ...args], {
10
- stdio: "inherit",
11
- });
13
+ if (result.error) {
14
+ throw result.error;
15
+ }
12
16
 
13
- child.on("exit", (code, signal) => {
14
- if (signal) {
15
- process.kill(process.pid, signal);
16
- } else if (code !== 0) {
17
- process.exit(code);
18
- }
19
- });
17
+ if (result.signal) {
18
+ process.kill(process.pid, result.signal);
19
+ } else {
20
+ process.exitCode = result.status ?? 1;
21
+ }
package/bin/utils.js CHANGED
@@ -1,6 +1,6 @@
1
- import { join } from "node:path";
1
+ import { dirname, join } from "node:path";
2
2
  import { fileURLToPath } from "node:url";
3
3
 
4
4
  export const getBinaryFilepath = (/** @type {string} */ specifier, /** @type {string} */ path) => {
5
- return join(fileURLToPath(import.meta.resolve(specifier)), path);
5
+ return join(dirname(fileURLToPath(import.meta.resolve(specifier))), path);
6
6
  };