I can't add a --filter argument to my composer.json script.
I've been reading up the docs but I can't seem to figure it out.
I have the following script in my composer.json
"scripts": {
"test": [
".\\vendor\\bin\\phpunit"
]
},
But I can't send any --filters with it like:
$ composer test --filter pigeon_ringnumber_cant_be_more_then_9_chars_for_BE_NL_ESP
This outputs the following error:
[Symfony\Component\Console\Exception\RuntimeException]
The "--filter" option does not exist.
Any idea how I can make the script accept the --filter argument?
I want to be able to run it quicker then always typing
.\\vendor\\bin\\phpunit
The key here is reading carefully the docs. In docs there is:
Similar to the run-script command you can give additional arguments to scripts, e.g. composer test -- --filter will pass --filter along to the phpunit script.
So to pass --filter pigeon_ringnumber_cant_be_more_then_9_chars_for_BE_NL_ESP you should in fact run:
composer test -- --filter pigeon_ringnumber_cant_be_more_then_9_chars_for_BE_NL_ESP
so you should use here additional -- before specifying arguments that you want to pass.
Of course in this case the solution you search might be much simpler. You could just consider creating symbolic link to do this.
Related
I am trying to accomplish the following -> Right now I use cypress to run e2e tests. It is being launched by npm command. I have several environments and different user permission. I created a shell script, where I have stored value of environment and user permission rights. What I want to do is to have opportunity to run npm command with parameters to change the value of variable from shell script. Could someone give a clue, is it even possible? The expected behaviour is to write something like:
npm run cy dev3,full
And have the opportunity to change the value of shell script variable to launch necessary environament and change value of user permissions.
package.json command:
"scripts": {
"cy": "./scripts/cypress.sh",
}
cypress.sh file content
#!/usr/bin/env bash
DEV_ENV="${DEV_ENV:-"dev3"}"
USER_TYPE="${USER_TYPE:-"full"}"
COMMAND="cypress open \
--browser chrome \
--config baseUrl=https://environment-$DEV_ENV.com \
--env DEV_ENV=https://environment-$DEV_ENV.com,USER_TYPE=$USER_TYPE
"
eval $COMMAND
Are you trying to change the environment variables seen in cypress.sh? If so, you can just execute npm run like this:
DEV_ENV=dev2 USER_TYPE=empty npm run cy
and it will change the value of DEV_ENV and USER_TYPE.
If you want to strictly run it by using the format you gave (npm run cy dev3,full), the args dev3,full are passed on to cypress.sh, so you can just parse the arguments directly in cypress.sh:
if [ ! -z "$1" ]; then
# do whatever here...
fi
In my CI build, I'd like to print a formatted string which is built from some nested commands by Docker like:
docker run -t --rm -v /mysrc:/src -w /src node:lts echo "My project uses `npm list aLibrary`"
On bash, the command echo "My project uses `npm list aLibrary`" just runs perfectly, but when passing to Docker, neither backtick`nor $() can be interpolated.
Anyone could help?
I've thought about making a .sh file to mount into the docker container, but a file would need a place to be stored, I think this simple CI script shouldn't be in a file.
Try:
bash -c 'echo "My project uses `npm list aLibrary`"'
this will work :
echo "My project uses `/usr/local/bin/npm list aLibrary`"
you need to supply the full path
Consider the following npm scripts.
$ npm run
available via `npm run-script`:
make
OUTPUT=dist/main.js bash -c 'elm make src/Main.js --output=$0 $1'
make:dev
npm run make -- '$OUTPUT' --debug
make:prod
npm run make -- '>(npm run uglify -- $OUTPUT)' --optimize
uglify
uglifyjs --compress 'pure_funcs="F2,F3,F4,F5,F6,F7,F8,F9,A2,A3,A4,A5,A6,A7,A8,A9",pure_getters,keep_fargs=false,unsafe_comps,unsafe' | uglifyjs --mangle --output=
I'd like to use it as follows:
$ npm run make -- '$OUTPUT' '--debug'
> experiment#0.1.0 experiment /Users/Adit/experiment
> OUTPUT=dist/main.js bash -c 'elm make src/Main.js --output=$0 $1' '$OUTPUT' '--debug'
This would correctly create the debug build of the Elm application. However, this is not what happens. Instead of using single quotes, npm run uses double quotes:
$ npm run make -- '$OUTPUT' '--debug'
> experiment#0.1.0 experiment /Users/Adit/experiment
> OUTPUT=dist/main.js bash -c 'elm make src/Main.js --output=$0 $1' "$OUTPUT" "--debug"
Due to this the output is not what I expect it to be. What's the best way to resolve this issue without writing a custom shell script? I want to use the OUTPUT variable in two different commands. However, I only want to define it in one place.
I solved the problem as follows.
{
"config": {
"input": "src/Main.elm",
"output": "dist/main.js"
},
"scripts": {
"make": "elm make $npm_package_config_input --output $npm_package_config_output",
"make:dev": "npm run make -- --debug",
"make:prod": "npm run make -- --optimize",
"postmake:prod": "uglifyjs $npm_package_config_output --compress 'pure_funcs=\"F2,F3,F4,F5,F6,F7,F8,F9,A2,A3,A4,A5,A6,A7,A8,A9\",pure_getters,keep_fargs=false,unsafe_comps,unsafe' | uglifyjs --mangle --output=$npm_package_config_output"
}
}
Hence, if you have a configuration variables that you'd like to use in multiple npm scripts, you can add them to the config dictionary of package.json. After that, you can access them as environment variables in the npm scripts via the name $npm_package_config_<name> where <name> is the name of your config variable.
I also used a post script instead of process substitution to uglify the output of the Elm compiler. Doing so was overall less of a hassle than using process substitution via bash -c.
Finally, you can run make, make:dev, or make:prod for different builds. The first one is a regular build. The second one is a development build with the Elm debugging tools. The third one is a regular build which is optimized and minified for production use.
Here's my Dockerfile:
FROM golang
RUN apt-get update
RUN go get -u github.com/golang/protobuf/{proto,protoc-gen-go}
This generates this error:
package github.com/golang/protobuf/{proto,protoc-gen-go}: invalid github.com/ import path "github.com/golang/protobuf/{proto,protoc-gen-go}"
But, if I take out that RUN directive, and just load up /bin/bash in the docker container, I can run the go get command just fine.
What's going on?
It's happening because the default shell is not /bin/bash, it's sh. You have two possible solutions, either you can explicitly define a shell in your RUN command like so:
RUN ["/bin/bash", "-c", "go get -u github.com/golang/protobuf/{proto,protoc-gen-go}"]
Or you can change the shell that RUN uses by default like so:
SHELL ["/bin/bash", "-c"]
RUN go get -u github.com/golang/protobuf/{proto,protoc-gen-go}
Source: https://docs.docker.com/engine/reference/builder/#/shell
It works if I use another shell, like bash, and put double quotes for the go command
RUN bash -c "go get github.com/golang/protobuf/{proto,protoc-gen-go}"
By the way, you can do all in only one RUN, see Dockerfiles best practices
https://docs.docker.com/engine/userguide/eng-image/dockerfile_best-practices/
I am using ec2-api-tools-1.6.7.3.
I want to delete a tag using CLI:
I have the CLI commands properly configured.
When i run
ec2-delete-tags -O <aws_access_key_id> -W <aws_secret_access_key> --region <my_region> <instance_id> --tag <my_tag>
it returns
TAG instance <instance_id> <my_tag> <my_tag_value>
However I see that the instance still has the tag available with it.I have also tried refreshing the console still no help.
Please include the actual cli command you are running, and the actual output - not the syntax.
Likely the issue is you are facing (but I cannot tell as the actual command is not provided) is your syntax on the --tag field itself which should be either:
--tag "TagKey=TagValue", or
--tag "TagKey"
Use the double quotes