【问题标题】:Composer post-install-cmd is failing with multiple commands in travis-ciComposer post-install-cmd 在 travis-ci 中使用多个命令失败
【发布时间】:2016-11-29 16:58:37
【问题描述】:

我正在学习构建一个易于协作和持续集成的项目。所以我为我的 WordPress 插件创建了一个branch

我通过以下方式制作了composer.json

"scripts": {
    "post-install-cmd": ["npm install", "grunt"],
    "pre-archive-cmd": "composer install"
}

它在我在 Windows 机器上的本地安装中做得很好,在运行 npm install 并加载其所有依赖项之后,它可以运行 grunt。但是使用 Travis CI 却失败了:

脚本 npm install && grunt 处理返回的 post-install-cmd 事件并返回错误代码 3
命令“composer install”失败并在 3 期间退出。

所以,我将命令更改为 this: "npm install && grunt" 也失败了。

然后我通过single command: "npm install" in post-install-cmd

我在这里做错了什么?为什么多个命令在本地环境中运行良好,但在 Travis CI 中却不行?错误代码 3 究竟是什么?

【问题讨论】:

    标签: wordpress npm gruntjs composer-php travis-ci


    【解决方案1】:

    我认为你需要告诉 travis 安装 npm 和 grunt 才能使用它。

    before_script:
    - npm install -g grunt-cli
    - npm install
    

    我在这里看到https://github.com/nanodesigns/nanosupport/blob/testing/.travis.yml 它在您的 travis 文件中丢失。

    更新: 您还需要使用 package.json 中的引擎指令指定节点版本:

    { "engines" : { "node" : ">=4" } }
    

    或通过 ENV 变量

    env:
      - TRAVIS_NODE_VERSION="4"
    

    【讨论】:

    • +1 的好建议。我错过了。但不知何故,grunt 命令的串联仍在努力通过 Travis-CI。 Build 1["npm install","grunt"]Build 2"npm install && grunt" 都未能通过 Composer.json 中的 post-install-cmd 声明
    • npm install 已经在 before_script 中执行,只在 post-install-cmd 中尝试 grunt
    • 但是postcss中出现错误:“Warning: Promise is not defined”,可能是使用了太旧的node版本
    • 问题不在于post-install-cmd 声明。感谢您的回答。它来自postcss,你是对的。让我深入研究一下。我尝试按照您的建议在packages.json 中提及节点版本,但仍然面临损坏的构建。无论如何,感谢您的回复。我接受了你的回答,因为它对post-install-cmd-specific 问题很中肯。
    • 到目前为止我发现,post-install-cmd 的语法与数组 ["npm install","grunt"] 是正确的。是否正确我可以在成功构建 inshALLAH 后确认。
    猜你喜欢
    • 1970-01-01
    • 2018-06-11
    • 1970-01-01
    • 1970-01-01
    • 2015-07-31
    • 2019-11-02
    • 1970-01-01
    相关资源
    最近更新 更多