|
6 | 6 | def phase_scalafmt(ctx, p): |
7 | 7 | if ctx.attr.format: |
8 | 8 | manifest, files = _build_format(ctx) |
9 | | - _format_runner(ctx, manifest, files) |
10 | | - _format_tester(ctx, manifest, files) |
| 9 | + _formatter(ctx, manifest, files, ctx.file._runner, ctx.outputs.scalafmt_runner) |
| 10 | + _formatter(ctx, manifest, files, ctx.file._testrunner, ctx.outputs.scalafmt_testrunner) |
11 | 11 | else: |
12 | 12 | ctx.actions.write( |
13 | 13 | output = ctx.outputs.scalafmt_runner, |
@@ -52,30 +52,16 @@ def _build_format(ctx): |
52 | 52 |
|
53 | 53 | return manifest, files |
54 | 54 |
|
55 | | -def _format_runner(ctx, manifest, files): |
| 55 | +def _formatter(ctx, manifest, files, input_runner, output_runner): |
56 | 56 | ctx.actions.run_shell( |
57 | | - inputs = [ctx.file._runner, manifest] + files, |
58 | | - outputs = [ctx.outputs.scalafmt_runner], |
| 57 | + inputs = [input_runner, manifest] + files, |
| 58 | + outputs = [output_runner], |
59 | 59 | command = "cat $1 | sed -e s#%workspace%#$2# -e s#%manifest%#$3# > $4", |
60 | 60 | arguments = [ |
61 | | - ctx.file._runner.path, |
| 61 | + input_runner.path, |
62 | 62 | ctx.workspace_name, |
63 | 63 | manifest.short_path, |
64 | | - ctx.outputs.scalafmt_runner.path, |
65 | | - ], |
66 | | - execution_requirements = {}, |
67 | | - ) |
68 | | - |
69 | | -def _format_tester(ctx, manifest, files): |
70 | | - ctx.actions.run_shell( |
71 | | - inputs = [ctx.file._testrunner, manifest] + files, |
72 | | - outputs = [ctx.outputs.scalafmt_testrunner], |
73 | | - command = "cat $1 | sed -e s#%workspace%#$2# -e s#%manifest%#$3# > $4", |
74 | | - arguments = [ |
75 | | - ctx.file._testrunner.path, |
76 | | - ctx.workspace_name, |
77 | | - manifest.short_path, |
78 | | - ctx.outputs.scalafmt_testrunner.path, |
| 64 | + output_runner.path, |
79 | 65 | ], |
80 | 66 | execution_requirements = {}, |
81 | 67 | ) |
0 commit comments