mirror of
				https://github.com/zulip/zulip-desktop.git
				synced 2025-11-04 14:03:27 +00:00 
			
		
		
		
	tools: Add tools for running typescript compiler and electron app.
This tool handles edge cases where all the typescript files might not be compiled when the electron process starts this defer that; it runs tsc compiler first. Next, we want to only run the compiler if the files are not compiled.
This commit is contained in:
		
				
					committed by
					
						
						Akash Nimare
					
				
			
			
				
	
			
			
			
						parent
						
							e4ef0e195a
						
					
				
				
					commit
					dd4f3047c3
				
			
							
								
								
									
										194
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										194
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							@@ -2082,188 +2082,6 @@
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    "concurrently": {
 | 
					 | 
				
			||||||
      "version": "4.1.0",
 | 
					 | 
				
			||||||
      "resolved": "https://registry.npmjs.org/concurrently/-/concurrently-4.1.0.tgz",
 | 
					 | 
				
			||||||
      "integrity": "sha512-pwzXCE7qtOB346LyO9eFWpkFJVO3JQZ/qU/feGeaAHiX1M3Rw3zgXKc5cZ8vSH5DGygkjzLFDzA/pwoQDkRNGg==",
 | 
					 | 
				
			||||||
      "dev": true,
 | 
					 | 
				
			||||||
      "requires": {
 | 
					 | 
				
			||||||
        "chalk": "^2.4.1",
 | 
					 | 
				
			||||||
        "date-fns": "^1.23.0",
 | 
					 | 
				
			||||||
        "lodash": "^4.17.10",
 | 
					 | 
				
			||||||
        "read-pkg": "^4.0.1",
 | 
					 | 
				
			||||||
        "rxjs": "^6.3.3",
 | 
					 | 
				
			||||||
        "spawn-command": "^0.0.2-1",
 | 
					 | 
				
			||||||
        "supports-color": "^4.5.0",
 | 
					 | 
				
			||||||
        "tree-kill": "^1.1.0",
 | 
					 | 
				
			||||||
        "yargs": "^12.0.1"
 | 
					 | 
				
			||||||
      },
 | 
					 | 
				
			||||||
      "dependencies": {
 | 
					 | 
				
			||||||
        "ansi-regex": {
 | 
					 | 
				
			||||||
          "version": "3.0.0",
 | 
					 | 
				
			||||||
          "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz",
 | 
					 | 
				
			||||||
          "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=",
 | 
					 | 
				
			||||||
          "dev": true
 | 
					 | 
				
			||||||
        },
 | 
					 | 
				
			||||||
        "camelcase": {
 | 
					 | 
				
			||||||
          "version": "5.3.1",
 | 
					 | 
				
			||||||
          "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz",
 | 
					 | 
				
			||||||
          "integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==",
 | 
					 | 
				
			||||||
          "dev": true
 | 
					 | 
				
			||||||
        },
 | 
					 | 
				
			||||||
        "cliui": {
 | 
					 | 
				
			||||||
          "version": "4.1.0",
 | 
					 | 
				
			||||||
          "resolved": "https://registry.npmjs.org/cliui/-/cliui-4.1.0.tgz",
 | 
					 | 
				
			||||||
          "integrity": "sha512-4FG+RSG9DL7uEwRUZXZn3SS34DiDPfzP0VOiEwtUWlE+AR2EIg+hSyvrIgUUfhdgR/UkAeW2QHgeP+hWrXs7jQ==",
 | 
					 | 
				
			||||||
          "dev": true,
 | 
					 | 
				
			||||||
          "requires": {
 | 
					 | 
				
			||||||
            "string-width": "^2.1.1",
 | 
					 | 
				
			||||||
            "strip-ansi": "^4.0.0",
 | 
					 | 
				
			||||||
            "wrap-ansi": "^2.0.0"
 | 
					 | 
				
			||||||
          }
 | 
					 | 
				
			||||||
        },
 | 
					 | 
				
			||||||
        "find-up": {
 | 
					 | 
				
			||||||
          "version": "3.0.0",
 | 
					 | 
				
			||||||
          "resolved": "https://registry.npmjs.org/find-up/-/find-up-3.0.0.tgz",
 | 
					 | 
				
			||||||
          "integrity": "sha512-1yD6RmLI1XBfxugvORwlck6f75tYL+iR0jqwsOrOxMZyGYqUuDhJ0l4AXdO1iX/FTs9cBAMEk1gWSEx1kSbylg==",
 | 
					 | 
				
			||||||
          "dev": true,
 | 
					 | 
				
			||||||
          "requires": {
 | 
					 | 
				
			||||||
            "locate-path": "^3.0.0"
 | 
					 | 
				
			||||||
          }
 | 
					 | 
				
			||||||
        },
 | 
					 | 
				
			||||||
        "has-flag": {
 | 
					 | 
				
			||||||
          "version": "2.0.0",
 | 
					 | 
				
			||||||
          "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-2.0.0.tgz",
 | 
					 | 
				
			||||||
          "integrity": "sha1-6CB68cx7MNRGzHC3NLXovhj4jVE=",
 | 
					 | 
				
			||||||
          "dev": true
 | 
					 | 
				
			||||||
        },
 | 
					 | 
				
			||||||
        "is-fullwidth-code-point": {
 | 
					 | 
				
			||||||
          "version": "2.0.0",
 | 
					 | 
				
			||||||
          "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz",
 | 
					 | 
				
			||||||
          "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=",
 | 
					 | 
				
			||||||
          "dev": true
 | 
					 | 
				
			||||||
        },
 | 
					 | 
				
			||||||
        "locate-path": {
 | 
					 | 
				
			||||||
          "version": "3.0.0",
 | 
					 | 
				
			||||||
          "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-3.0.0.tgz",
 | 
					 | 
				
			||||||
          "integrity": "sha512-7AO748wWnIhNqAuaty2ZWHkQHRSNfPVIsPIfwEOWO22AmaoVrWavlOcMR5nzTLNYvp36X220/maaRsrec1G65A==",
 | 
					 | 
				
			||||||
          "dev": true,
 | 
					 | 
				
			||||||
          "requires": {
 | 
					 | 
				
			||||||
            "p-locate": "^3.0.0",
 | 
					 | 
				
			||||||
            "path-exists": "^3.0.0"
 | 
					 | 
				
			||||||
          }
 | 
					 | 
				
			||||||
        },
 | 
					 | 
				
			||||||
        "p-limit": {
 | 
					 | 
				
			||||||
          "version": "2.2.0",
 | 
					 | 
				
			||||||
          "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.2.0.tgz",
 | 
					 | 
				
			||||||
          "integrity": "sha512-pZbTJpoUsCzV48Mc9Nh51VbwO0X9cuPFE8gYwx9BTCt9SF8/b7Zljd2fVgOxhIF/HDTKgpVzs+GPhyKfjLLFRQ==",
 | 
					 | 
				
			||||||
          "dev": true,
 | 
					 | 
				
			||||||
          "requires": {
 | 
					 | 
				
			||||||
            "p-try": "^2.0.0"
 | 
					 | 
				
			||||||
          }
 | 
					 | 
				
			||||||
        },
 | 
					 | 
				
			||||||
        "p-locate": {
 | 
					 | 
				
			||||||
          "version": "3.0.0",
 | 
					 | 
				
			||||||
          "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-3.0.0.tgz",
 | 
					 | 
				
			||||||
          "integrity": "sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ==",
 | 
					 | 
				
			||||||
          "dev": true,
 | 
					 | 
				
			||||||
          "requires": {
 | 
					 | 
				
			||||||
            "p-limit": "^2.0.0"
 | 
					 | 
				
			||||||
          }
 | 
					 | 
				
			||||||
        },
 | 
					 | 
				
			||||||
        "p-try": {
 | 
					 | 
				
			||||||
          "version": "2.2.0",
 | 
					 | 
				
			||||||
          "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz",
 | 
					 | 
				
			||||||
          "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==",
 | 
					 | 
				
			||||||
          "dev": true
 | 
					 | 
				
			||||||
        },
 | 
					 | 
				
			||||||
        "parse-json": {
 | 
					 | 
				
			||||||
          "version": "4.0.0",
 | 
					 | 
				
			||||||
          "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-4.0.0.tgz",
 | 
					 | 
				
			||||||
          "integrity": "sha1-vjX1Qlvh9/bHRxhPmKeIy5lHfuA=",
 | 
					 | 
				
			||||||
          "dev": true,
 | 
					 | 
				
			||||||
          "requires": {
 | 
					 | 
				
			||||||
            "error-ex": "^1.3.1",
 | 
					 | 
				
			||||||
            "json-parse-better-errors": "^1.0.1"
 | 
					 | 
				
			||||||
          }
 | 
					 | 
				
			||||||
        },
 | 
					 | 
				
			||||||
        "path-exists": {
 | 
					 | 
				
			||||||
          "version": "3.0.0",
 | 
					 | 
				
			||||||
          "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz",
 | 
					 | 
				
			||||||
          "integrity": "sha1-zg6+ql94yxiSXqfYENe1mwEP1RU=",
 | 
					 | 
				
			||||||
          "dev": true
 | 
					 | 
				
			||||||
        },
 | 
					 | 
				
			||||||
        "read-pkg": {
 | 
					 | 
				
			||||||
          "version": "4.0.1",
 | 
					 | 
				
			||||||
          "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-4.0.1.tgz",
 | 
					 | 
				
			||||||
          "integrity": "sha1-ljYlN48+HE1IyFhytabsfV0JMjc=",
 | 
					 | 
				
			||||||
          "dev": true,
 | 
					 | 
				
			||||||
          "requires": {
 | 
					 | 
				
			||||||
            "normalize-package-data": "^2.3.2",
 | 
					 | 
				
			||||||
            "parse-json": "^4.0.0",
 | 
					 | 
				
			||||||
            "pify": "^3.0.0"
 | 
					 | 
				
			||||||
          }
 | 
					 | 
				
			||||||
        },
 | 
					 | 
				
			||||||
        "string-width": {
 | 
					 | 
				
			||||||
          "version": "2.1.1",
 | 
					 | 
				
			||||||
          "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz",
 | 
					 | 
				
			||||||
          "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==",
 | 
					 | 
				
			||||||
          "dev": true,
 | 
					 | 
				
			||||||
          "requires": {
 | 
					 | 
				
			||||||
            "is-fullwidth-code-point": "^2.0.0",
 | 
					 | 
				
			||||||
            "strip-ansi": "^4.0.0"
 | 
					 | 
				
			||||||
          }
 | 
					 | 
				
			||||||
        },
 | 
					 | 
				
			||||||
        "strip-ansi": {
 | 
					 | 
				
			||||||
          "version": "4.0.0",
 | 
					 | 
				
			||||||
          "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz",
 | 
					 | 
				
			||||||
          "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=",
 | 
					 | 
				
			||||||
          "dev": true,
 | 
					 | 
				
			||||||
          "requires": {
 | 
					 | 
				
			||||||
            "ansi-regex": "^3.0.0"
 | 
					 | 
				
			||||||
          }
 | 
					 | 
				
			||||||
        },
 | 
					 | 
				
			||||||
        "supports-color": {
 | 
					 | 
				
			||||||
          "version": "4.5.0",
 | 
					 | 
				
			||||||
          "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-4.5.0.tgz",
 | 
					 | 
				
			||||||
          "integrity": "sha1-vnoN5ITexcXN34s9WRJQRJEvY1s=",
 | 
					 | 
				
			||||||
          "dev": true,
 | 
					 | 
				
			||||||
          "requires": {
 | 
					 | 
				
			||||||
            "has-flag": "^2.0.0"
 | 
					 | 
				
			||||||
          }
 | 
					 | 
				
			||||||
        },
 | 
					 | 
				
			||||||
        "yargs": {
 | 
					 | 
				
			||||||
          "version": "12.0.5",
 | 
					 | 
				
			||||||
          "resolved": "https://registry.npmjs.org/yargs/-/yargs-12.0.5.tgz",
 | 
					 | 
				
			||||||
          "integrity": "sha512-Lhz8TLaYnxq/2ObqHDql8dX8CJi97oHxrjUcYtzKbbykPtVW9WB+poxI+NM2UIzsMgNCZTIf0AQwsjK5yMAqZw==",
 | 
					 | 
				
			||||||
          "dev": true,
 | 
					 | 
				
			||||||
          "requires": {
 | 
					 | 
				
			||||||
            "cliui": "^4.0.0",
 | 
					 | 
				
			||||||
            "decamelize": "^1.2.0",
 | 
					 | 
				
			||||||
            "find-up": "^3.0.0",
 | 
					 | 
				
			||||||
            "get-caller-file": "^1.0.1",
 | 
					 | 
				
			||||||
            "os-locale": "^3.0.0",
 | 
					 | 
				
			||||||
            "require-directory": "^2.1.1",
 | 
					 | 
				
			||||||
            "require-main-filename": "^1.0.1",
 | 
					 | 
				
			||||||
            "set-blocking": "^2.0.0",
 | 
					 | 
				
			||||||
            "string-width": "^2.0.0",
 | 
					 | 
				
			||||||
            "which-module": "^2.0.0",
 | 
					 | 
				
			||||||
            "y18n": "^3.2.1 || ^4.0.0",
 | 
					 | 
				
			||||||
            "yargs-parser": "^11.1.1"
 | 
					 | 
				
			||||||
          }
 | 
					 | 
				
			||||||
        },
 | 
					 | 
				
			||||||
        "yargs-parser": {
 | 
					 | 
				
			||||||
          "version": "11.1.1",
 | 
					 | 
				
			||||||
          "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-11.1.1.tgz",
 | 
					 | 
				
			||||||
          "integrity": "sha512-C6kB/WJDiaxONLJQnF8ccx9SEeoTTLek8RVbaOIsrAUS8VrBEXfmeSnCZxygc+XC2sNMBIwOOnfcxiynjHsVSQ==",
 | 
					 | 
				
			||||||
          "dev": true,
 | 
					 | 
				
			||||||
          "requires": {
 | 
					 | 
				
			||||||
            "camelcase": "^5.0.0",
 | 
					 | 
				
			||||||
            "decamelize": "^1.2.0"
 | 
					 | 
				
			||||||
          }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
      }
 | 
					 | 
				
			||||||
    },
 | 
					 | 
				
			||||||
    "configstore": {
 | 
					    "configstore": {
 | 
				
			||||||
      "version": "3.1.2",
 | 
					      "version": "3.1.2",
 | 
				
			||||||
      "resolved": "https://registry.npmjs.org/configstore/-/configstore-3.1.2.tgz",
 | 
					      "resolved": "https://registry.npmjs.org/configstore/-/configstore-3.1.2.tgz",
 | 
				
			||||||
@@ -2583,12 +2401,6 @@
 | 
				
			|||||||
        "assert-plus": "^1.0.0"
 | 
					        "assert-plus": "^1.0.0"
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    "date-fns": {
 | 
					 | 
				
			||||||
      "version": "1.30.1",
 | 
					 | 
				
			||||||
      "resolved": "https://registry.npmjs.org/date-fns/-/date-fns-1.30.1.tgz",
 | 
					 | 
				
			||||||
      "integrity": "sha512-hBSVCvSmWC+QypYObzwGOd9wqdDpOt+0wl0KbU+R+uuZBS1jN8VsD1ss3irQDknRj5NvxiTF6oj/nDRnN/UQNw==",
 | 
					 | 
				
			||||||
      "dev": true
 | 
					 | 
				
			||||||
    },
 | 
					 | 
				
			||||||
    "date-now": {
 | 
					    "date-now": {
 | 
				
			||||||
      "version": "0.1.4",
 | 
					      "version": "0.1.4",
 | 
				
			||||||
      "resolved": "https://registry.npmjs.org/date-now/-/date-now-0.1.4.tgz",
 | 
					      "resolved": "https://registry.npmjs.org/date-now/-/date-now-0.1.4.tgz",
 | 
				
			||||||
@@ -10280,12 +10092,6 @@
 | 
				
			|||||||
      "integrity": "sha1-Gsu/tZJDbRC76PeFt8xvgoFQEsM=",
 | 
					      "integrity": "sha1-Gsu/tZJDbRC76PeFt8xvgoFQEsM=",
 | 
				
			||||||
      "dev": true
 | 
					      "dev": true
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    "spawn-command": {
 | 
					 | 
				
			||||||
      "version": "0.0.2-1",
 | 
					 | 
				
			||||||
      "resolved": "https://registry.npmjs.org/spawn-command/-/spawn-command-0.0.2-1.tgz",
 | 
					 | 
				
			||||||
      "integrity": "sha1-YvXpRmmBwbeW3Fkpk34RycaSG9A=",
 | 
					 | 
				
			||||||
      "dev": true
 | 
					 | 
				
			||||||
    },
 | 
					 | 
				
			||||||
    "spawn-sync": {
 | 
					    "spawn-sync": {
 | 
				
			||||||
      "version": "1.0.15",
 | 
					      "version": "1.0.15",
 | 
				
			||||||
      "resolved": "https://registry.npmjs.org/spawn-sync/-/spawn-sync-1.0.15.tgz",
 | 
					      "resolved": "https://registry.npmjs.org/spawn-sync/-/spawn-sync-1.0.15.tgz",
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -21,8 +21,7 @@
 | 
				
			|||||||
    "node": ">=6.0.0"
 | 
					    "node": ">=6.0.0"
 | 
				
			||||||
  },
 | 
					  },
 | 
				
			||||||
  "scripts": {
 | 
					  "scripts": {
 | 
				
			||||||
    "start": "concurrently --kill-others npm:start-app npm:watch-ts",
 | 
					    "start": "node tools/run-dev",
 | 
				
			||||||
    "start-app": "electron app --disable-http-cache --no-electron-connect",
 | 
					 | 
				
			||||||
    "watch-ts": "tsc -w",
 | 
					    "watch-ts": "tsc -w",
 | 
				
			||||||
    "reinstall": "node ./tools/reinstall-node-modules.js",
 | 
					    "reinstall": "node ./tools/reinstall-node-modules.js",
 | 
				
			||||||
    "postinstall": "electron-builder install-app-deps",
 | 
					    "postinstall": "electron-builder install-app-deps",
 | 
				
			||||||
@@ -135,7 +134,6 @@
 | 
				
			|||||||
    "@typescript-eslint/eslint-plugin": "1.10.2",
 | 
					    "@typescript-eslint/eslint-plugin": "1.10.2",
 | 
				
			||||||
    "@typescript-eslint/parser": "1.10.2",
 | 
					    "@typescript-eslint/parser": "1.10.2",
 | 
				
			||||||
    "assert": "1.4.1",
 | 
					    "assert": "1.4.1",
 | 
				
			||||||
    "concurrently": "4.1.0",
 | 
					 | 
				
			||||||
    "cp-file": "5.0.0",
 | 
					    "cp-file": "5.0.0",
 | 
				
			||||||
    "devtron": "1.4.0",
 | 
					    "devtron": "1.4.0",
 | 
				
			||||||
    "electron": "3.1.10",
 | 
					    "electron": "3.1.10",
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										89
									
								
								tools/run-dev
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										89
									
								
								tools/run-dev
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,89 @@
 | 
				
			|||||||
 | 
					#!/usr/bin/env node
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const path = require('path');
 | 
				
			||||||
 | 
					const glob = require('glob');
 | 
				
			||||||
 | 
					const chalk = require('chalk');
 | 
				
			||||||
 | 
					const { spawn } = require('child_process');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					async function run(task, commandToRun, opts = {}) {
 | 
				
			||||||
 | 
					  const args = commandToRun.split(' ');
 | 
				
			||||||
 | 
					  let cmd = args[0];
 | 
				
			||||||
 | 
					  args.splice(0, 1);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  if (process.platform === 'win32' && /np(m|x)/.test(cmd)) {
 | 
				
			||||||
 | 
					    cmd = cmd + '.cmd';
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  const defaults = {
 | 
				
			||||||
 | 
					    cwd: path.resolve(__dirname, '..'),
 | 
				
			||||||
 | 
					    env: process.env,
 | 
				
			||||||
 | 
					    stdio: 'pipe'
 | 
				
			||||||
 | 
					  };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  opts = { ...defaults, ...opts };
 | 
				
			||||||
 | 
					  task = ' ' + task + ' ';
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
 | 
					  const colors = [
 | 
				
			||||||
 | 
					    { bg: 'bold.bgGreen', color: 'bold.green' },
 | 
				
			||||||
 | 
					    { bg: 'bold.bgMagenta', color: 'bold.magenta' },
 | 
				
			||||||
 | 
					    { bg: 'bold.bgBlue', color: 'bold.blue' },
 | 
				
			||||||
 | 
					    { bg: 'bold.bgYellow', color: 'bold.yellow' },
 | 
				
			||||||
 | 
					    { bg: 'bold.bgCyan', color: 'bold.cyan' },
 | 
				
			||||||
 | 
					    { bg: 'bold.bgKeyword("rebeccapurple")', color: 'bold.keyword("rebeccapurple")' },
 | 
				
			||||||
 | 
					    { bg: 'bold.bgKeyword("darkslategray")', color: 'bold.keyword("darkslategray")' },
 | 
				
			||||||
 | 
					  ];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  const randomColorIndex = Math.floor((Math.random() * (colors.length * 1000)) / 1000);
 | 
				
			||||||
 | 
					  const randomColor = colors[randomColorIndex];
 | 
				
			||||||
 | 
					  console.log(chalk`{${randomColor.bg} ${ task }} {${randomColor.color} ${commandToRun}}`);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  const proc = spawn(cmd, args, opts);
 | 
				
			||||||
 | 
					  proc.stderr.on('data', data => console.log(data.toString()));
 | 
				
			||||||
 | 
					  proc.stdout.on('data', data => console.log(data.toString()));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  return new Promise((resolve, reject) => {
 | 
				
			||||||
 | 
					    function check(code) {
 | 
				
			||||||
 | 
					      if (code !== 0) {
 | 
				
			||||||
 | 
					        reject(chalk`{bgRed ERROR!} Running {red ${commandToRun}} failed with exit code: ${code}`);
 | 
				
			||||||
 | 
					      } else {
 | 
				
			||||||
 | 
					        resolve();
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      // we don't want to exit after compiling typescript files
 | 
				
			||||||
 | 
					      // but instead want to do it if the tsc -w or electron app died.
 | 
				
			||||||
 | 
					      if (commandToRun !== 'npx tsc') {
 | 
				
			||||||
 | 
					        process.exit(0); 
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    proc.on('exit', check);
 | 
				
			||||||
 | 
					    proc.on('close', check);
 | 
				
			||||||
 | 
					    proc.on('error', () => {
 | 
				
			||||||
 | 
					      reject();
 | 
				
			||||||
 | 
					      process.exit(0);
 | 
				
			||||||
 | 
					    });
 | 
				
			||||||
 | 
					  });
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					async function main() {
 | 
				
			||||||
 | 
					  const baseFilePattern = 'app/+(main|renderer)/**/*';
 | 
				
			||||||
 | 
					  const globOptions = { cwd: path.resolve(__dirname, '..') };
 | 
				
			||||||
 | 
					  const jsFiles = glob.sync(baseFilePattern + '.js', globOptions);
 | 
				
			||||||
 | 
					  const tsFiles = glob.sync(baseFilePattern + '.ts', globOptions);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  // if the are missing compiled js file for typescript files
 | 
				
			||||||
 | 
					  // run the typescript compiler before starting the app
 | 
				
			||||||
 | 
					  if (jsFiles.length !== tsFiles.length) {
 | 
				
			||||||
 | 
					    console.log('Compiling typescript files...');
 | 
				
			||||||
 | 
					    await run('TypeScript', 'npx tsc');
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  await Promise.all([
 | 
				
			||||||
 | 
					    run('Electron app', 'npx electron app --disable-http-cache --no-electron-connect'),
 | 
				
			||||||
 | 
					    run('TypeScript watch mode', 'npx tsc --watch --pretty')
 | 
				
			||||||
 | 
					  ]);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					main()
 | 
				
			||||||
 | 
					  .catch(err => console.error(err));
 | 
				
			||||||
		Reference in New Issue
	
	Block a user