x3d-tidy 1.0.48 → 1.0.49

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/x3d-tidy.js CHANGED
@@ -1,17 +1,10 @@
1
1
  #!/usr/bin/env node
2
2
  "use strict"
3
3
 
4
- const path = require ("path")
5
- const { execFile } = require ("child_process")
4
+ const os = require ("os")
5
+ const { spawn } = require ("child_process")
6
6
 
7
- execFile ("npm", ["start", "--", ... process .argv .slice (2)], (error, stdout, stderr) =>
8
- {
9
- if (error)
10
- return process .stderr .write (error .message)
7
+ const p = spawn (os .platform () === "win32" ? "npm.cmd" : "npm", ["start", "--silent", "--", ... process .argv .slice (2)])
11
8
 
12
- if (stdout)
13
- process .stdout .write (stdout)
14
-
15
- if (stderr)
16
- process .stderr .write (stderr)
17
- })
9
+ p .stdout .pipe (process .stdout)
10
+ p .stderr .pipe (process .stderr)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "x3d-tidy",
3
- "version": "1.0.48",
3
+ "version": "1.0.49",
4
4
  "description": "X3D Converter, Beautifier and Minimizer",
5
5
  "bin": {
6
6
  "x3d-tidy": "bin/x3d-tidy.js"
@@ -41,6 +41,7 @@
41
41
  },
42
42
  "homepage": "https://www.npmjs.com/package/x3d-tidy",
43
43
  "dependencies": {
44
+ "console": "^0.7.2",
44
45
  "electron": "^25.1.1",
45
46
  "x_ite": "^8.9.1",
46
47
  "yargs": "^17.7.2"
package/src/convert.js CHANGED
@@ -1,21 +1,26 @@
1
1
  "use strict"
2
2
 
3
3
  const
4
- X3D = require ("x_ite"),
5
- infer = require ("./infer"),
6
- pkg = require ("../package.json"),
7
- metadata = require ("./metadata"),
8
- electron = require ("electron"),
9
- yargs = require ("yargs"),
10
- url = require ("url"),
11
- path = require ("path"),
12
- fs = require ("fs"),
13
- zlib = require ("zlib"),
14
- DEBUG = false
4
+ X3D = require ("x_ite"),
5
+ infer = require ("./infer"),
6
+ pkg = require ("../package.json"),
7
+ metadata = require ("./metadata"),
8
+ electron = require ("electron"),
9
+ yargs = require ("yargs"),
10
+ url = require ("url"),
11
+ path = require ("path"),
12
+ fs = require ("fs"),
13
+ zlib = require ("zlib"),
14
+ nodeConsole = require ("console"),
15
+ DEBUG = false
15
16
 
16
17
  // DEBUG: npm start -- --version` to reset cache.
17
18
 
18
- process .exit = (status) => electron .ipcRenderer .send (status ? "error" : "ready", "")
19
+ console = nodeConsole .Console (process .stdout, process .stderr)
20
+
21
+ process .exit = (status) => electron .ipcRenderer .send (status ? "error" : "ready", "")
22
+ process .stdout .write = (message) => electron .ipcRenderer .send ("output", message)
23
+ process .stderr .write = (message) => electron .ipcRenderer .send ("error", message)
19
24
 
20
25
  electron .ipcRenderer .on ("convert", async (event, argv) => main (argv))
21
26
 
@@ -35,10 +40,6 @@ async function main (argv)
35
40
 
36
41
  async function convert (argv)
37
42
  {
38
- console .log = output .bind (null, process .stdout)
39
- console .warn = output .bind (null, process .stdout)
40
- console .error = output .bind (null, process .stderr)
41
-
42
43
  const args = yargs (argv)
43
44
  .scriptName ("x3d-tidy")
44
45
  .usage ("$0 args")
@@ -197,9 +198,4 @@ ${scene .toXMLString ({ html: true, indent: " " .repeat (6) })}
197
198
  <p>Made with <a href="https://www.npmjs.com/package/x3d-tidy" target="_blank">x3d-tidy.</a></p>
198
199
  </body>
199
200
  </html>`
200
- }
201
-
202
- function output (stdout, ... args)
203
- {
204
- stdout .write (args .join (" ") + "\n")
205
201
  }
package/src/main.js CHANGED
@@ -5,6 +5,7 @@ const
5
5
  path = require ("path")
6
6
 
7
7
  process .env .ELECTRON_DISABLE_SECURITY_WARNINGS = "true"
8
+ process .env .ELECTRON_ENABLE_LOGGING = 1
8
9
 
9
10
  if (process .platform === "darwin")
10
11
  {
@@ -27,11 +28,16 @@ electron .app .whenReady () .then (async () =>
27
28
 
28
29
  electron .ipcMain .on ("ready", () => electron .app .quit ())
29
30
 
31
+ electron .ipcMain .on ("output", (event, message) =>
32
+ {
33
+ process .stderr .write (message)
34
+ process .stderr .write ("\n")
35
+ })
36
+
30
37
  electron .ipcMain .on ("error", (event, message) =>
31
38
  {
32
39
  process .stderr .write (message)
33
40
  process .stderr .write ("\n")
34
- process .exit (1)
35
41
  })
36
42
 
37
43
  await window .loadFile (path .join (__dirname, "window.html"))