在composer.json中运行命令行命令 [英] Run command line command in composer.json

查看:108
本文介绍了在composer.json中运行命令行命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试编写一个composer.json文件,该文件将连续运行多个命令行命令,因此,例如以下示例:

I'm trying to write a composer.json file that will run several command line commands in a row so just as an example something like this:

"scripts": {
   "test": [
        "@createDir"
   ],
   "createDir": "mkdir testing"

}

当我使用在终端中运行作曲器文件时虽然没有创建composer.phar update 目录。有人可以指出正确的方向怎么做或我做错了吗?

When I run the composer file in terminal using composer.phar update the directory isn't created though. Can anybody point me in the right direction how to do this or what I'm doing wrong?

推荐答案

Composer无法运行默认情况下,所有脚本均在安装更新结束时进行。为此,您的脚本必须位于 命令事件之一下 键,例如更新后cmd

Composer doesn't run all scripts by default at the end of an install or update. For that to happen, your script needs to be under one of the Command Event keys, e.g. post-update-cmd.

您仍然可以在这些块中引用其他脚本,例如

You can still reference other scripts within these blocks, e.g.

"scripts": {
    "post-install-cmd": [
        "@test"
    ],
    "test": [
        "touch foo"
    ]
}

要运行单个脚本,请使用 run-script 命令:

To run an individual script, you use the run-script command:

composer run-script test

这篇关于在composer.json中运行命令行命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆