From a96844118c24d870abfe5332547dab99dc53d09c Mon Sep 17 00:00:00 2001 From: David Sherret Date: Sat, 27 May 2023 10:33:15 -0400 Subject: fix(compile): inline symlinks as files outside node_modules dir and warn for directories (#19285) If a symlink within the `node_modules` directory lies outside that directory, it will now warn and inline the file. For directories, it will just warn for now. Probably fixes #19251 (I'm still unable to reproduce). --- cli/tests/testdata/compile/node_modules_symlink_outside/main.out | 2 ++ cli/tests/testdata/compile/node_modules_symlink_outside/main.ts | 6 ++++++ .../compile/node_modules_symlink_outside/main_compile_file.out | 2 ++ .../compile/node_modules_symlink_outside/main_compile_folder.out | 6 ++++++ 4 files changed, 16 insertions(+) create mode 100644 cli/tests/testdata/compile/node_modules_symlink_outside/main.out create mode 100644 cli/tests/testdata/compile/node_modules_symlink_outside/main.ts create mode 100644 cli/tests/testdata/compile/node_modules_symlink_outside/main_compile_file.out create mode 100644 cli/tests/testdata/compile/node_modules_symlink_outside/main_compile_folder.out (limited to 'cli/tests/testdata') diff --git a/cli/tests/testdata/compile/node_modules_symlink_outside/main.out b/cli/tests/testdata/compile/node_modules_symlink_outside/main.out new file mode 100644 index 000000000..61c83cba4 --- /dev/null +++ b/cli/tests/testdata/compile/node_modules_symlink_outside/main.out @@ -0,0 +1,2 @@ +4 +5 diff --git a/cli/tests/testdata/compile/node_modules_symlink_outside/main.ts b/cli/tests/testdata/compile/node_modules_symlink_outside/main.ts new file mode 100644 index 000000000..45f681f7c --- /dev/null +++ b/cli/tests/testdata/compile/node_modules_symlink_outside/main.ts @@ -0,0 +1,6 @@ +import { getValue, setValue } from "npm:@denotest/esm-basic"; + +setValue(4); + +console.log(getValue()); +console.log(Deno.readTextFileSync("./node_modules/test.txt")); diff --git a/cli/tests/testdata/compile/node_modules_symlink_outside/main_compile_file.out b/cli/tests/testdata/compile/node_modules_symlink_outside/main_compile_file.out new file mode 100644 index 000000000..7602a4002 --- /dev/null +++ b/cli/tests/testdata/compile/node_modules_symlink_outside/main_compile_file.out @@ -0,0 +1,2 @@ +Compile file:///[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. diff --git a/cli/tests/testdata/compile/node_modules_symlink_outside/main_compile_folder.out b/cli/tests/testdata/compile/node_modules_symlink_outside/main_compile_folder.out new file mode 100644 index 000000000..883a3f262 --- /dev/null +++ b/cli/tests/testdata/compile/node_modules_symlink_outside/main_compile_folder.out @@ -0,0 +1,6 @@ +Download http://localhost:4545/npm/registry/@denotest/esm-basic +Download http://localhost:4545/npm/registry/@denotest/esm-basic/1.0.0.tgz +Initialize @denotest/esm-basic@1.0.0 +Check file:///[WILDCARD]/node_modules_symlink_outside/main.ts +Compile file:///[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'. -- cgit v1.2.3