diff --git a/package.json b/package.json index 2fe790dc85..d3713bb75a 100644 --- a/package.json +++ b/package.json @@ -33,9 +33,9 @@ "debug-unittest": "DEBUG=1 npm run unittest", "e2etest": "python scripts/test/run_test_suite.py --test-suite=e2e", "eslint-test": "mocha \"./scripts/eslint_rules/tests/*_test.js\"", + "generate-bridge-file": "tsc -p scripts/component_bridges/tsconfig.json && node scripts/component_bridges/gen/cli.js", "generate-bridges-test": "tsc -p test/unittests/scripts/component_bridges/tsconfig.json && mocha test/unittests/scripts/component_bridges/**/*_test.js", "generate-protocol-resources": "python scripts/deps/generate_protocol_resources.py && git cl format --js", - "generate-bridge-file": "tsc -p scripts/component_bridges/tsconfig.json && node scripts/component_bridges/gen/cli.js", "install-deps": "PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true python scripts/deps/manage_node_deps.py", "interactive-screenshottest": "INTERACTIVE=1 python scripts/test/run_test_suite.py --test-suite=screenshots", "optimize-svg-images": "python scripts/optimize_svg_images.py", @@ -47,7 +47,7 @@ "start": "node scripts/hosted_mode/start_chrome_and_server.js", "test": "node scripts/npm_test.js", "test-local": "node scripts/npm_test.js --layout-tests-directory=test/webtests/", - "unittest": "NO_TEXT_COVERAGE=1 python scripts/test/run_unittests.py", - "ts_library-test": "./third_party/typescript/tests/verify_ts_libary.sh" + "ts_library-test": "./third_party/typescript/tests/verify_ts_libary.sh", + "unittest": "NO_TEXT_COVERAGE=1 python scripts/test/run_unittests.py" } -} +} \ No newline at end of file diff --git a/scripts/deps/manage_node_deps.py b/scripts/deps/manage_node_deps.py index 57521f5382..84bc93b2b3 100644 --- a/scripts/deps/manage_node_deps.py +++ b/scripts/deps/manage_node_deps.py @@ -65,8 +65,8 @@ DEPS = { def exec_command(cmd): try: cmd_proc_result = subprocess.check_call(cmd, cwd=devtools_paths.root_path()) - except Error as error: - print(error.output) + except Exception as error: + print(error) return True return False @@ -93,7 +93,6 @@ def strip_private_fields(): for pkg in packages: with open(pkg, 'r+') as pkg_file: - prop_removal_count = 0 try: pkg_data = json.load(pkg_file) @@ -102,12 +101,10 @@ def strip_private_fields(): for key in pkg_data.keys(): if key.find(u'_') == 0: pkg_data.pop(key) - prop_removal_count = prop_removal_count + 1 pkg_file.truncate(0) pkg_file.seek(0) json.dump(pkg_data, pkg_file, indent=2, sort_keys=True, separators=(',', ': ')) - print("(%s): %s" % (prop_removal_count, pkg)) except: print('Unable to fix: %s' % pkg) return True @@ -115,6 +112,7 @@ def strip_private_fields(): return False +# Required to keep the package-lock.json in sync with the package.json dependencies def install_missing_deps(): with open(devtools_paths.package_lock_json_path(), 'r+') as pkg_lock_file: try: @@ -188,37 +186,49 @@ def addClangFormat(): return False -def install_deps(): +def run_npm_command(npm_command_args=None): for (name, version) in DEPS.items(): if (version.find(u'^') == 0): print('Versions must be locked to a specific version; remove ^ from the start of the version.') return True + run_custom_command = npm_command_args is not None + if append_package_json_entries(): return True if install_missing_deps(): return True - # Run the CI version of npm, which prevents updates to the versions of modules. + # By default, run the CI version of npm, which prevents updates to the versions of modules. if exec_command(['npm', 'ci']): return True + if run_custom_command: + custom_command_result = exec_command(['npm'] + npm_command_args) + + if remove_package_json_entries(): + return True + if strip_private_fields(): return True - if remove_package_json_entries(): - return True - if addClangFormat(): return True + if run_custom_command: + return custom_command_result + return ensure_licenses() -npm_errors_found = install_deps() +npm_args = None + +if (len(sys.argv[1:]) > 0): + npm_args = sys.argv[1:] + +npm_errors_found = run_npm_command(npm_args) if npm_errors_found: - print('npm installation failed') -else: - print('npm installation successful') + print('npm command failed') + exit(1)