I'm getting the following error when trying to run a bash script in Composer post install/update hooks:
> post-install.sh
sh: 1: post-install.sh: not found
Script post-install.sh handling the post-install-cmd event returned with an error
[RuntimeException]
Error Output: sh: 1: post-install.sh: not found
Original composer.json
Works but it's just annoying to update the post install/update commands to run in two places.
{
"require": {
"twbs/bootstrap": "3.3.5"
...
...
},
"scripts": {
"post-install-cmd": [
"mkdir -p _libraries",
"cp -r vendor/twbs/bootstrap/dist _libraries/bootstrap/",
...
...
],
"post-update-cmd": [
"mkdir -p _libraries",
"cp -r vendor/twbs/bootstrap/dist _libraries/bootstrap/",
...
...
]
}
}
According to the Composer documentation:
A script, in Composer's terms, can either be a PHP callback (defined
as a static method) or any command-line executable command.
So my composer.json
should be able to work as such:
Wanted composer.json
{
"require": {
"twbs/bootstrap": "3.3.5"
...
...
},
"scripts": {
"post-install-cmd": [
"post-install.sh"
],
"post-update-cmd": [
"post-install.sh"
]
}
}
post-install.sh
Executable by everyone (0775
) and located in the same directory as the composer.json
#!/bin/bash
mkdir -p _libraries
cp -r vendor/twbs/bootstrap/dist _libraries/bootstrap/
...
...
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…