@ugo-studio/jspp 0.2.7 → 0.2.8

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,6 +1,6 @@
1
1
  {
2
2
  "name": "@ugo-studio/jspp",
3
- "version": "0.2.7",
3
+ "version": "0.2.8",
4
4
  "description": "A modern transpiler that converts JavaScript code into high-performance, standard C++23.",
5
5
  "main": "dist/index.js",
6
6
  "module": "src/index.ts",
@@ -77,6 +77,8 @@ async function precompileHeaders() {
77
77
  }
78
78
 
79
79
  console.log(`[${mode.name.toUpperCase()}] Compiling header...`);
80
+ const tempGchPath = `${gchPath}.tmp`;
81
+
80
82
  const compile = spawnSync(
81
83
  "g++",
82
84
  [
@@ -86,7 +88,7 @@ async function precompileHeaders() {
86
88
  ...mode.flags,
87
89
  headerPath,
88
90
  "-o",
89
- gchPath,
91
+ tempGchPath,
90
92
  "-I",
91
93
  PRELUDE_DIR,
92
94
  ],
@@ -96,11 +98,16 @@ async function precompileHeaders() {
96
98
  );
97
99
 
98
100
  if (compile.status !== 0) {
101
+ if (await fs.stat(tempGchPath).then(() => true, () => false)) {
102
+ await fs.unlink(tempGchPath);
103
+ }
99
104
  console.error(
100
105
  `[${mode.name.toUpperCase()}] Failed to precompile headers.`,
101
106
  );
102
107
  process.exit(1);
103
108
  }
109
+
110
+ await fs.rename(tempGchPath, gchPath);
104
111
  console.log(`[${mode.name.toUpperCase()}] Success.`);
105
112
  }
106
113
  } catch (error: any) {