@manuelp1345/graph-generator 1.2.10 → 1.2.11

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. package/dist/cli.js +5 -10
  2. package/package.json +1 -1
  3. package/src/cli.ts +7 -11
package/dist/cli.js CHANGED
@@ -10,21 +10,16 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  import { exec } from "child_process";
12
12
  import { promisify } from "util";
13
- const command = process.argv[2]; // Esto puede ser el comando 'codegen'
14
- if (command === "codegen") {
15
- runCodegen(); // Ejecuta la función de generación del esquema
16
- }
17
- else {
18
- console.log("Comando desconocido");
19
- }
13
+ // Promisify exec to use async/await
20
14
  const execPromise = promisify(exec);
15
+ // Función para ejecutar el comando de generación de código
21
16
  function runCodegen() {
22
17
  return __awaiter(this, void 0, void 0, function* () {
23
18
  try {
24
- const { stdout, stderr } = yield execPromise("npx graphql-codegen --config src/codegen.ts");
25
- console.log(stdout);
19
+ const { stdout, stderr } = yield execPromise("graphql-codegen --config dist/codegen.js");
20
+ console.log("stdout:", stdout);
26
21
  if (stderr) {
27
- console.error(stderr);
22
+ console.error("stderr:", stderr);
28
23
  }
29
24
  }
30
25
  catch (error) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@manuelp1345/graph-generator",
3
- "version": "1.2.10",
3
+ "version": "1.2.11",
4
4
  "description": "generador de schema y types de graphql",
5
5
  "scripts": {
6
6
  "codegen": "graphql-codegen --config src/codegen.ts",
package/src/cli.ts CHANGED
@@ -1,25 +1,21 @@
1
1
  #!/usr/bin/env node
2
+
2
3
  import { exec } from "child_process";
3
4
  import { promisify } from "util";
4
5
 
5
- const command = process.argv[2]; // Esto puede ser el comando 'codegen'
6
-
7
- if (command === "codegen") {
8
- runCodegen(); // Ejecuta la función de generación del esquema
9
- } else {
10
- console.log("Comando desconocido");
11
- }
12
-
6
+ // Promisify exec to use async/await
13
7
  const execPromise = promisify(exec);
14
8
 
9
+ // Función para ejecutar el comando de generación de código
15
10
  async function runCodegen() {
16
11
  try {
17
12
  const { stdout, stderr } = await execPromise(
18
- "npx graphql-codegen --config src/codegen.ts"
13
+ "graphql-codegen --config dist/codegen.js"
19
14
  );
20
- console.log(stdout);
15
+
16
+ console.log("stdout:", stdout);
21
17
  if (stderr) {
22
- console.error(stderr);
18
+ console.error("stderr:", stderr);
23
19
  }
24
20
  } catch (error) {
25
21
  console.error("Error executing graphql-codegen:", error);