Skip to content

Commit

Permalink
refactor: remove 'abspath' usage
Browse files Browse the repository at this point in the history
  • Loading branch information
vindard committed Oct 16, 2023
1 parent 23391c7 commit 9b23dd5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 16 deletions.
8 changes: 3 additions & 5 deletions toolchains/workspace-pnpm/macros.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -574,17 +574,15 @@ def _npm_test_impl(

pnpm_toolchain = ctx.attrs._workspace_pnpm_toolchain[WorkspacePnpmToolchainInfo]

exec_cmd = cmd_args(program_run_info, format = "{}::abspath")

run_cmd_args = cmd_args([
ctx.attrs._python_toolchain[PythonToolchainInfo].interpreter,
pnpm_toolchain.run_in_dir[DefaultInfo].default_outputs,
"--cwd",
cmd_args([build_context.workspace_root, ctx.label.package], delimiter = "/"),
"--",
exec_cmd,
"--bin",
cmd_args(program_run_info),
program_args,
])
run_cmd_args.add(program_args)

args_file = ctx.actions.write("args.txt", run_cmd_args)

Expand Down
17 changes: 6 additions & 11 deletions toolchains/workspace-pnpm/run_in_dir.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,19 @@ def compute_path(arg: str) -> str:
"--cwd",
help="Directory under which to run the program",
)
parser.add_argument(
"--bin",
help="Binary to execute program with",
)
parser.add_argument(
"args",
help="Program and arguments",
nargs=argparse.REMAINDER,
)

args = parser.parse_args()
args.args.pop(0) # pops the '--' separator off

cwd = args.cwd

cmd = []
for arg in args.args:
cmd.append(compute_path(arg))
cmd = [os.path.abspath(args.bin), *args.args]

exit_code = subprocess.call(cmd, cwd=cwd)
exit_code = subprocess.call(cmd, cwd=args.cwd)

sys.exit(exit_code)



0 comments on commit 9b23dd5

Please sign in to comment.