我试图在Composer包中安装后安装和发布更新脚本。这是composer.json
文件的摘录:
"autoload": {
"psr-4": {
"App\\": "src/"
}
},
"scripts": {
"post-update-cmd": [
"App\\Install\\ComposerScripts::postUpdate"
],
"post-install-cmd": [
"App\\Install\\ComposerScripts::postInstall",
"./test.sh"
]
}
这是ComposerScripts.php
:
<?php
namespace App\Install;
use Composer\Script\Event;
class ComposerScripts
{
public static function postInstall(Event $event)
{
$io = $event->getIO();
if ($io->askConfirmation('Install Mecab? ', false)) {
return true;
}
exit;
}
public static function postUpdate(Event $event)
{
$event->getIO()->write("Working!");
return true;
}
}
文件test.sh
:
#!/bin/sh
echo Working
如果我使用composer run-script
测试它们并且test.sh
脚本工作正常,则ComposerScripts方法有效,但是当我安装或更新包时,根本没有任何事情发生。没有输出,没有错误,没有。知道这里发生了什么吗?