bug: additionalFiles copies ../ matches outside the build on Windows

未关闭
#5,074 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

  • #5075 来自 @SimoMay —— 已关闭,未合并

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
35/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
停滞
领域
build-system

调研方向

Start with packages/build/src/internal/copyFiles.ts and inspect findFilesByMatchers, focusing on how relative() paths are split and joined. Use the included path.win32 reproduction to confirm the Windows behavior, then verify the destination resolves to <build>/shared/a.md on both Windows and POSIX paths. A linked pull request, #5075, already addresses this issue.

由索引模型根据 Issue 内容生成。

描述

Provide environment information

  • OS: Windows (fails); macOS and Linux are not affected
  • trigger.dev CLI and @trigger.dev/build: 4.5.16
  • The same code is in 4.8.1 and on main

Describe the bug

additionalFiles is meant to strip leading .. segments so that a pattern like ../shared/** copies files inside the build output. On Windows the segments are not stripped, and the files are copied outside the build directory. The deploy goes ahead without them.

The cause is findFilesByMatchers in packages/build/src/internal/copyFiles.ts:

const pathInsideDestinationDir = relative(cwd, file)
  .split(posix.sep)
  .filter((p) => p !== "..")
  .join(posix.sep);

On Windows, relative() returns a backslash path (..\shared\a.md). Splitting on / gives one segment, so no .. is removed, and join(destinationDir, "..\shared\a.md") resolves outside the build directory, one level up for each ...

Expected: the files land at <build>/shared/a.md on every OS, as they do on macOS and Linux.

Reproduction repo

No repo needed. The Node script below runs the same path logic with path.win32, on any OS.

To reproduce

const { win32, posix } = require("node:path");
const cwd = "C:\\repo\\app";
const file = "C:\\repo\\shared\\a.md";
const dest = "C:\\repo\\app\\.trigger\\tmp\\build-x";

const inside = win32.relative(cwd, file).split(posix.sep).filter((p) => p !== "..").join(posix.sep);
console.log(win32.join(dest, inside));
// C:\repo\app\.trigger\tmp\shared\a.md   <- outside build-x

End to end, on Windows:

  1. In a project one level below the repo root, add additionalFiles({ files: ["../shared/**"] }) to trigger.config.ts.
  2. Run npx trigger.dev deploy.
  3. The deployed image has no shared/ folder. The same deploy from macOS includes it.

A task that reads one of those files at runtime then fails with a missing file.

Suggested fix

Split on the platform separator, and keep joining with / (join accepts it on Windows):

const pathInsideDestinationDir = relative(cwd, file)
  .split(sep)
  .filter((p) => p !== "..")
  .join(posix.sep);

With path.win32 and path.posix, both resolve to <build>/shared/a.md. A PR with this change follows.

主要语言
TypeScript
星标
16.5k
派生
1.5k
平均合并
1 天 15 小时
30 天内合并 PR
17

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

triggerdotdev/trigger.dev 的其他 Issue

查看 triggerdotdev/trigger.dev 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。