@create-node-app/core 0.1.3 → 0.1.4

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/dist/index.js CHANGED
@@ -679,6 +679,20 @@ var install = (root, useYarn = false, dependencies = [], verbose = false, isOnli
679
679
  });
680
680
  });
681
681
  };
682
+ var runCommandInProjectDir = (root, command, args = [], successMessage = "Operation completed successfully.", errorMessage = "Operation failed.") => {
683
+ return new Promise((resolve, reject) => {
684
+ const child = (0, import_cross_spawn2.default)(command, args, { stdio: "inherit", cwd: root });
685
+ child.on("close", (code) => {
686
+ if (code !== 0) {
687
+ console.log(import_chalk3.default.red(errorMessage));
688
+ reject(new Error(`${command} ${args.join(" ")}`));
689
+ return;
690
+ }
691
+ console.log(import_chalk3.default.green(successMessage));
692
+ resolve();
693
+ });
694
+ });
695
+ };
682
696
  var run = async ({
683
697
  root,
684
698
  appName,
@@ -759,18 +773,36 @@ var run = async ({
759
773
  JSON.stringify(packageJson, null, 2) + import_os3.default.EOL
760
774
  );
761
775
  }
762
- (0, import_cross_spawn2.default)("git", ["init"], {
776
+ const gitInitProcess = (0, import_cross_spawn2.default)("git", ["init"], {
763
777
  cwd: root
764
778
  });
779
+ gitInitProcess.on("close", (code) => {
780
+ if (code !== 0) {
781
+ console.log(import_chalk3.default.red("Failed to initialize git repository."));
782
+ return;
783
+ }
784
+ console.log(import_chalk3.default.green("Initialized git repository."));
785
+ });
765
786
  if (installDependencies && isOnline) {
766
787
  const packageJson = JSON.parse(
767
788
  import_fs5.default.readFileSync(`${root}/package.json`, "utf8")
768
789
  );
769
790
  if (packageJson.scripts && packageJson.scripts["format"]) {
770
- (0, import_cross_spawn2.default)(runCommand, ["format"], { stdio: "inherit", cwd: root });
791
+ await runCommandInProjectDir(
792
+ root,
793
+ runCommand,
794
+ ["format"],
795
+ "Successfully formatted code."
796
+ );
771
797
  }
772
798
  if (packageJson.scripts && packageJson.scripts["lint:fix"]) {
773
- (0, import_cross_spawn2.default)(runCommand, ["lint:fix"], { stdio: "inherit", cwd: root });
799
+ await runCommandInProjectDir(
800
+ root,
801
+ runCommand,
802
+ ["lint:fix"],
803
+ "Successfully fixed linting errors.",
804
+ "Failed to fix linting errors."
805
+ );
774
806
  }
775
807
  }
776
808
  };
package/dist/index.mjs CHANGED
@@ -651,6 +651,20 @@ var install = (root, useYarn = false, dependencies = [], verbose = false, isOnli
651
651
  });
652
652
  });
653
653
  };
654
+ var runCommandInProjectDir = (root, command, args = [], successMessage = "Operation completed successfully.", errorMessage = "Operation failed.") => {
655
+ return new Promise((resolve, reject) => {
656
+ const child = spawn2(command, args, { stdio: "inherit", cwd: root });
657
+ child.on("close", (code) => {
658
+ if (code !== 0) {
659
+ console.log(chalk3.red(errorMessage));
660
+ reject(new Error(`${command} ${args.join(" ")}`));
661
+ return;
662
+ }
663
+ console.log(chalk3.green(successMessage));
664
+ resolve();
665
+ });
666
+ });
667
+ };
654
668
  var run = async ({
655
669
  root,
656
670
  appName,
@@ -731,18 +745,36 @@ var run = async ({
731
745
  JSON.stringify(packageJson, null, 2) + os3.EOL
732
746
  );
733
747
  }
734
- spawn2("git", ["init"], {
748
+ const gitInitProcess = spawn2("git", ["init"], {
735
749
  cwd: root
736
750
  });
751
+ gitInitProcess.on("close", (code) => {
752
+ if (code !== 0) {
753
+ console.log(chalk3.red("Failed to initialize git repository."));
754
+ return;
755
+ }
756
+ console.log(chalk3.green("Initialized git repository."));
757
+ });
737
758
  if (installDependencies && isOnline) {
738
759
  const packageJson = JSON.parse(
739
760
  fs4.readFileSync(`${root}/package.json`, "utf8")
740
761
  );
741
762
  if (packageJson.scripts && packageJson.scripts["format"]) {
742
- spawn2(runCommand, ["format"], { stdio: "inherit", cwd: root });
763
+ await runCommandInProjectDir(
764
+ root,
765
+ runCommand,
766
+ ["format"],
767
+ "Successfully formatted code."
768
+ );
743
769
  }
744
770
  if (packageJson.scripts && packageJson.scripts["lint:fix"]) {
745
- spawn2(runCommand, ["lint:fix"], { stdio: "inherit", cwd: root });
771
+ await runCommandInProjectDir(
772
+ root,
773
+ runCommand,
774
+ ["lint:fix"],
775
+ "Successfully fixed linting errors.",
776
+ "Failed to fix linting errors."
777
+ );
746
778
  }
747
779
  }
748
780
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@create-node-app/core",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",