From 3656d12cba2b94605f6bf593104e5939693f9d8a Mon Sep 17 00:00:00 2001 From: Samuel Attard Date: Sun, 10 Mar 2019 16:24:27 -0700 Subject: [PATCH] build: auto generate electron.d.ts in the spec runner if it is missing --- script/spec-runner.js | 15 +++++++++++++++ spec/package-lock.json | 20 ++++++++++---------- spec/package.json | 2 +- 3 files changed, 26 insertions(+), 11 deletions(-) diff --git a/script/spec-runner.js b/script/spec-runner.js index 3f7770819c2e..ac3c27beb644 100755 --- a/script/spec-runner.js +++ b/script/spec-runner.js @@ -33,9 +33,24 @@ async function main () { await getSpecHash().then(saveSpecHash) } + if (!fs.existsSync(path.resolve(__dirname, '../electron.d.ts'))) { + console.log('Generating electron.d.ts as it is missing') + generateTypeDefinitions() + } + await runElectronTests() } +function generateTypeDefinitions () { + const { status } = childProcess.spawnSync('npm', ['run', 'create-typescript-definitions'], { + cwd: path.resolve(__dirname, '..'), + stdio: 'inherit' + }) + if (status !== 0) { + throw new Error(`Electron typescript definition generation failed with exit code: ${status}.`) + } +} + function loadLastSpecHash () { return fs.existsSync(specHashPath) ? fs.readFileSync(specHashPath, 'utf8').split('\n') diff --git a/spec/package-lock.json b/spec/package-lock.json index 5a35468488d6..a07b78a129c5 100644 --- a/spec/package-lock.json +++ b/spec/package-lock.json @@ -5,9 +5,9 @@ "requires": true, "dependencies": { "abstract-socket": { - "version": "github:nornagon/node-abstractsocket#7d9c770f9ffef14373349034f8820ff059879845", - "from": "github:nornagon/node-abstractsocket#v8-compat", - "dev": true, + "version": "2.0.0", + "resolved": "github:nornagon/node-abstractsocket#7d9c770f9ffef14373349034f8820ff059879845", + "optional": true, "requires": { "bindings": "^1.2.1", "nan": "^2.0.9" @@ -65,14 +65,14 @@ "version": "1.4.0", "resolved": "https://registry.npmjs.org/bindings/-/bindings-1.4.0.tgz", "integrity": "sha512-7znEVX22Djn+nYjxCWKDne0RRloa9XfYa84yk3s+HkE3LpDYZmhArYr9O9huBoHY3/oXispx5LorIX7Sl2CgSQ==", - "dev": true, + "optional": true, "requires": { "file-uri-to-path": "1.0.0" } }, "bl": { "version": "1.2.2", - "resolved": "https://registry.npmjs.org/bl/-/bl-1.2.2.tgz", + "resolved": "http://registry.npmjs.org/bl/-/bl-1.2.2.tgz", "integrity": "sha512-e8tQYnZodmebYDWGH7KMRvtzKXaJHx3BbilrgZCfvyLUYdKpK1t5PSPmpkny/SgiTSCnjfLW7v5rlONXVFkQEA==", "optional": true, "requires": { @@ -468,7 +468,7 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz", "integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==", - "dev": true + "optional": true }, "find-up": { "version": "3.0.0", @@ -785,7 +785,7 @@ }, "minimist": { "version": "1.2.0", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", + "resolved": "http://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=" }, "mkdirp": { @@ -984,7 +984,7 @@ }, "os-homedir": { "version": "1.0.2", - "resolved": "https://registry.npmjs.org/os-homedir/-/os-homedir-1.0.2.tgz", + "resolved": "http://registry.npmjs.org/os-homedir/-/os-homedir-1.0.2.tgz", "integrity": "sha1-/7xJiDNuDoM94MFox+8VISGqf7M=", "optional": true }, @@ -1156,7 +1156,7 @@ }, "readable-stream": { "version": "2.3.6", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", + "resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", "requires": { "core-util-is": "~1.0.0", @@ -1365,7 +1365,7 @@ }, "string_decoder": { "version": "1.1.1", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "resolved": "http://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", "requires": { "safe-buffer": "~5.1.0" diff --git a/spec/package.json b/spec/package.json index 38f6f328994f..fb0ddcaa2884 100644 --- a/spec/package.json +++ b/spec/package.json @@ -7,7 +7,6 @@ "postinstall": "node ../tools/run-if-exists.js node_modules/robotjs node-gyp rebuild" }, "devDependencies": { - "abstract-socket": "github:nornagon/node-abstractsocket#v8-compat", "basic-auth": "^2.0.1", "bluebird": "^3.5.3", "chai": "^4.2.0", @@ -33,6 +32,7 @@ "yargs": "^12.0.5" }, "optionalDependencies": { + "abstract-socket": "github:nornagon/node-abstractsocket#v8-compat", "robotjs": "github:nornagon/robotjs#node-12" } }