gpt4 book ai didi

bash - Composer 无法运行安装后脚本

转载 作者:行者123 更新时间:2023-11-29 08:48:16 25 4
gpt4 key购买 nike

尝试在 Composer 安装后/更新 Hook 中运行 bash 脚本时出现以下错误:

> 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

原始 composer.json

可行,但更新安装后/更新命令以在两个地方运行很烦人。

{
"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/",
...
...
]
}
}

根据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.

所以我的 composer.json 应该能够这样工作:

想要 composer.json

{
"require": {
"twbs/bootstrap": "3.3.5"
...
...
},
"scripts": {
"post-install-cmd": [
"post-install.sh"
],
"post-update-cmd": [
"post-install.sh"
]
}
}

post-install.sh

所有人都可执行 (0775) 并且与 composer.json 位于同一目录

#!/bin/bash

mkdir -p _libraries
cp -r vendor/twbs/bootstrap/dist _libraries/bootstrap/
...
...

最佳答案

实现单个任务定义的其他方法是referencing scripts :

{
"require": {
"twbs/bootstrap": "3.3.5"
...
},
"scripts": {
"your-cmd": [
"mkdir -p _libraries",
"cp -r vendor/twbs/bootstrap/dist _libraries/bootstrap/",
...
],
"post-install-cmd": [
"@your-cmd",
...
],
"post-update-cmd": [
"@your-cmd",
...
]
}
}

关于bash - Composer 无法运行安装后脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33550138/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com