From c2230ca76a02fc5b67092431079c4e96c15aaed2 Mon Sep 17 00:00:00 2001 From: Zeke Sikelianos Date: Fri, 31 Mar 2017 21:35:58 -0700 Subject: [PATCH] generate electron.d.ts during dist creation, not during build --- package.json | 2 -- script/cibuild | 3 --- script/create-dist.py | 12 +++++++++--- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index 350ece717b..4a18f2004f 100644 --- a/package.json +++ b/package.json @@ -33,8 +33,6 @@ "clean": "python ./script/clean.py", "clean-build": "python ./script/clean.py --build", "coverage": "npm run instrument-code-coverage && npm test -- --use-instrumented-asar", - "generate-api-json": "electron-docs-linter docs/api --version=$npm_package_version --outfile=out/electron-api.json", - "generate-typescript-definitions": "electron-typescript-definitions --in=out/electron-api.json --out=out/electron.d.ts", "instrument-code-coverage": "electabul instrument --input-path ./lib --output-path ./out/coverage/electron.asar", "lint": "npm run lint-js && npm run lint-cpp && npm run lint-py && npm run lint-api-docs-js && npm run lint-api-docs", "lint-js": "standard && cd spec && standard", diff --git a/script/cibuild b/script/cibuild index 4d43a7f011..3a77b32352 100755 --- a/script/cibuild +++ b/script/cibuild @@ -82,9 +82,6 @@ def main(): sys.stderr.flush() execute([npm, 'run', 'lint']) - sys.stderr.write('\nRunning `npm run generate-typescript-definitions`\n') - sys.stderr.flush() - execute([npm, 'run', 'generate-typescript-definitions']) if is_release: run_script('build.py', ['-c', 'R']) run_script('create-dist.py') diff --git a/script/create-dist.py b/script/create-dist.py index 4737fc7cd5..b5351df9a6 100755 --- a/script/create-dist.py +++ b/script/create-dist.py @@ -92,7 +92,7 @@ def main(): if PLATFORM != 'win32' and not args.no_api_docs: create_api_json_schema() - copy_typescript_definitions() + create_typescript_definitions() if PLATFORM == 'linux': strip_binaries() @@ -145,8 +145,14 @@ def create_api_json_schema(): '--version={}'.format(ELECTRON_VERSION.replace('v', ''))], env=env) -def copy_typescript_definitions(): - shutil.copy2(os.path.join(SOURCE_ROOT, 'out', 'electron.d.ts'), DIST_DIR) +def create_typescript_definitions(): + node_bin_dir = os.path.join(SOURCE_ROOT, 'node_modules', '.bin') + env = os.environ.copy() + env['PATH'] = os.path.pathsep.join([node_bin_dir, env['PATH']]) + infile = os.path.relpath(os.path.join(DIST_DIR, 'electron-api.json')) + outfile = os.path.relpath(os.path.join(DIST_DIR, 'electron.d.ts')) + execute(['electron-typescript-definitions', '--in={0}'.format(infile), + '--out={0}'.format(outfile)], env=env) def strip_binaries(): for binary in TARGET_BINARIES[PLATFORM]: