Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit dccbb63

Browse files
authoredAug 16, 2022
fix: ts_project fail if root_dir used deep in source tree (#3535)
1 parent 371e8ca commit dccbb63

File tree

4 files changed

+7
-1
lines changed

4 files changed

+7
-1
lines changed
 

‎nodejs/private/ts_lib.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ def _out_paths(srcs, out_dir, root_dir, allow_js, ext_map):
169169
outs = []
170170
for f in srcs:
171171
if _is_ts_src(f, allow_js):
172-
out = _join(out_dir, f[:f.rindex(".")].replace(rootdir_replace_pattern, "") + _replace_ext(f, ext_map))
172+
out = _join(out_dir, f[:f.rindex(".")].replace(rootdir_replace_pattern, "", 1) + _replace_ext(f, ext_map))
173173

174174
# Don't declare outputs that collide with inputs
175175
# for example, a.js -> a.js

‎packages/typescript/test/ts_project/rootdir_with_value/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ load("//packages/typescript:index.bzl", "ts_project")
55
SRCS = [
66
"subdir/a.ts",
77
"subdir/file.json",
8+
"subdir/deep/subdir/b.ts",
89
]
910

1011
ts_project(
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const a: string = 'so many folders...';

‎packages/typescript/test/ts_project/rootdir_with_value/verify.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,7 @@ const assert = require('assert');
22

33
const files = process.argv.slice(2);
44
assert.ok(files.some(f => f.endsWith('rootdir_with_value/a.js')), 'Missing a.js');
5+
6+
// Test that the only the top-level matching "rootdir" is removed.
7+
// NOTE: This should never fail directly, as the bug being fixed is a build-time error.
8+
assert.ok(files.some(f => f.endsWith('rootdir_with_value/deep/subdir/b.js')), 'Missing b.js');

0 commit comments

Comments
 (0)
Please sign in to comment.