diff options
author | 木杉 <zhmushan@qq.com> | 2020-07-21 22:47:55 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-21 16:47:55 +0200 |
commit | f34a441a7d3e3e5c1517207a1ee2ed2a0eaee0c9 (patch) | |
tree | bad5f251ebe9dcd2ab28e19db21e82f63e97e23e | |
parent | 2460689b1a9582ef6ab8c5fa429e281c88bc14d1 (diff) |
fix(tools/lint): don't exceed max command line length on windows (#6804)
-rwxr-xr-x | tools/lint.py | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/tools/lint.py b/tools/lint.py index 0ff0b16d7..a964179fb 100755 --- a/tools/lint.py +++ b/tools/lint.py @@ -71,15 +71,24 @@ def eslint(): ":!:cli/tests/lint/**", ]) if source_files: - print_command("eslint", source_files) - # Set NODE_PATH so we don't have to maintain a symlink in root_path. - env = os.environ.copy() - env["NODE_PATH"] = os.path.join(root_path, "third_party", - "node_modules") - run(["node", script, "--max-warnings=0", "--"] + source_files, - shell=False, - env=env, - quiet=True) + max_command_len = 30000 + pre_command = ["node", script, "--max-warnings=0", "--"] + chunks = [[]] + cmd_len = len(" ".join(pre_command)) + for f in source_files: + if cmd_len + len(f) > max_command_len: + chunks.append([f]) + cmd_len = len(" ".join(pre_command)) + else: + chunks[-1].append(f) + cmd_len = cmd_len + len(f) + 1 + for c in chunks: + print_command("eslint", c) + # Set NODE_PATH so we don't have to maintain a symlink in root_path. + env = os.environ.copy() + env["NODE_PATH"] = os.path.join(root_path, "third_party", + "node_modules") + run(pre_command + c, shell=False, env=env, quiet=True) def pylint(): |