Ubuntu runner 不展开双星

问题描述 投票:0回答:1

我在

package.json
中有以下测试命令:

    "test": "node --test --enable-source-maps --loader ts-node/esm lib/**/*.test.ts && node --test index.test.js"

它在本地运行,但在 CI 上失败:

yarn run v1.22.21
$ node --test --enable-source-maps --loader ts-node/esm lib/**/*.test.ts && node --test index.test.js
Could not find '/home/runner/work/assert-raisins/assert-raisins/lib/**/*.test.ts'

看起来

**
没有被扩展。我尝试在任何地方插入
shopt -s globstar
,但无济于事。

完整工作流程 YAML:

name: Node.js CI

on:
  push:
    branches: [ "master" ]
  pull_request:
    branches: [ "master" ]

jobs:
  test:
    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v3
    - name: Setup node
      uses: actions/setup-node@v3
      with:
        cache: 'npm'
    - run: yarn
    - name: Run tests
      run: yarn test
node.js github-actions yarnpkg
1个回答
0
投票

NPM 脚本默认使用

sh
中的
PATH
。在某些系统(如 macOS)上,这个“sh”实际上只是伪装的
bash
,但在 Github Action Runner 中似乎并非如此。

sh

不同,

bash
 不支持 globstar,因此您需要更改 NPM 要使用的 shell。这可以通过将 
.npmrc
 文件添加到您的项目,并将 
script-shell 选项
 设置为 
bash
来完成。
    

© www.soinside.com 2019 - 2024. All rights reserved.