不可能,因为所有不包含
我在Makefile
中创建了一个工作目标,称为test-path-testname
:
## Runs tests that match a file pattern and test name to speed up test time
test-path-testname: ensure-env
docker-compose run -p 9229:9229
-e TYPEORM_URL=postgres://postgres@postgres/someapp_test
-e DATABASE_URL_READONLY=postgres://postgres@postgres/someapp_test
server npm run test-all -t $(path) --
--detectOpenHandles --watchAll --verbose=false -t "$(testname)"
.PHONY: test-path-testname
使用path
和testname
参数,它的功能非常完美:
make path=usersArea testname="should create a new user" test-path-testname
然而,这个命令很长-有没有办法在Makefile
中使用位置参数而不是命名参数
例如,我希望能够运行上面的:
make usersArea "should create a new user" test-path-testname
=
的非选项都被视为目标。
在你的评论后编辑,并解释动机:
您正在解决XY问题。不要选择更多的变量,而是用替换来拆分目标名称$@
:
test-path-testname:
@echo path=$(word 2,$(subst -, ,$@)) testname=$(word 3,$(subst -, ,$@))
docker-compose ... -t $(word 3,$(subst -, ,$@)) ...
这假设目标名称中正好有两个连字符。