forked from denoland/deno
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(compile/npm): ignore symlinks to non-existent paths in node_modul…
…es directory (denoland#21479) Part of denoland#21476
- Loading branch information
Showing
8 changed files
with
92 additions
and
27 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1062,6 +1062,44 @@ fn compile_node_modules_symlink_outside() { | |
output.assert_matches_file("compile/node_modules_symlink_outside/main.out"); | ||
} | ||
|
||
#[test] | ||
fn compile_node_modules_symlink_non_existent() { | ||
let context = TestContextBuilder::for_npm().use_temp_cwd().build(); | ||
let temp_dir = context.temp_dir().path(); | ||
temp_dir.join("main.ts").write( | ||
r#"import { getValue, setValue } from "npm:@denotest/esm-basic"; | ||
setValue(4); | ||
console.log(getValue());"#, | ||
); | ||
let node_modules_dir = temp_dir.join("node_modules"); | ||
node_modules_dir.create_dir_all(); | ||
// create a symlink that points to a non_existent file | ||
node_modules_dir.symlink_dir("non_existent", "folder"); | ||
// compile folder | ||
let output = context | ||
.new_command() | ||
.args("compile --allow-read --node-modules-dir --output bin main.ts") | ||
.run(); | ||
output.assert_exit_code(0); | ||
output.assert_matches_text( | ||
r#"Download http:https://localhost:4545/npm/registry/@denotest/esm-basic | ||
Download http:https://localhost:4545/npm/registry/@denotest/esm-basic/1.0.0.tgz | ||
Initialize @denotest/[email protected] | ||
Check file:https:///[WILDCARD]/main.ts | ||
Compile file:https:///[WILDCARD]/main.ts to [WILDCARD] | ||
Warning Failed resolving symlink. Ignoring. | ||
Path: [WILDCARD] | ||
Message: [WILDCARD]) | ||
"#, | ||
); | ||
|
||
// run | ||
let binary_path = | ||
temp_dir.join(if cfg!(windows) { "bin.exe" } else { "bin" }); | ||
let output = context.new_command().name(binary_path).run(); | ||
output.assert_matches_text("4\n"); | ||
} | ||
|
||
#[test] | ||
fn dynamic_imports_tmp_lit() { | ||
let context = TestContextBuilder::new().build(); | ||
|
2 changes: 1 addition & 1 deletion
2
cli/tests/testdata/compile/node_modules_symlink_outside/main_compile_file.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
Compile file:https:///[WILDCARD]/node_modules_symlink_outside/main.ts to [WILDCARD] | ||
Symlink target is outside '[WILDCARD]node_modules_symlink_outside[WILDCARD]node_modules'. Inlining symlink at '[WILDCARD]node_modules_symlink_outside[WILDCARD]node_modules[WILDCARD]test.txt' to '[WILDCARD]node_modules_symlink_outside[WILDCARD]test.txt' as file. | ||
Warning Symlink target is outside '[WILDCARD]node_modules_symlink_outside[WILDCARD]node_modules'. Inlining symlink at '[WILDCARD]node_modules_symlink_outside[WILDCARD]node_modules[WILDCARD]test.txt' to '[WILDCARD]node_modules_symlink_outside[WILDCARD]test.txt' as file. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,4 @@ Download http:https://localhost:4545/npm/registry/@denotest/esm-basic/1.0.0.tgz | |
Initialize @denotest/[email protected] | ||
Check file:https:///[WILDCARD]/node_modules_symlink_outside/main.ts | ||
Compile file:https:///[WILDCARD]/node_modules_symlink_outside/main.ts to [WILDCARD] | ||
Symlink target is outside '[WILDCARD]node_modules_symlink_outside[WILDCARD]node_modules'. Excluding symlink at '[WILDCARD]node_modules_symlink_outside[WILDCARD]node_modules[WILDCARD]some_folder' with target '[WILDCARD]node_modules_symlink_outside[WILDCARD]some_folder'. | ||
Warning Symlink target is outside '[WILDCARD]node_modules_symlink_outside[WILDCARD]node_modules'. Excluding symlink at '[WILDCARD]node_modules_symlink_outside[WILDCARD]node_modules[WILDCARD]some_folder' with target '[WILDCARD]node_modules_symlink_outside[WILDCARD]some_folder'. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters