diff --git a/cli/standalone/virtual_fs.rs b/cli/standalone/virtual_fs.rs index 5b8076549d1700..b630f629c5a8f0 100644 --- a/cli/standalone/virtual_fs.rs +++ b/cli/standalone/virtual_fs.rs @@ -329,7 +329,7 @@ impl VfsBuilder { let dir = self.add_dir(path.parent().unwrap())?; let name = path.file_name().unwrap().to_string_lossy(); match dir.entries.binary_search_by(|e| e.name().cmp(&name)) { - Ok(_) => unreachable!(), + Ok(_) => Ok(()), // previously inserted Err(insert_index) => { dir.entries.insert( insert_index, @@ -341,9 +341,9 @@ impl VfsBuilder { .collect::>(), }), ); + Ok(()) } } - Ok(()) } pub fn into_dir_and_files(self) -> (VirtualDirectory, Vec>) { diff --git a/tests/specs/compile/include/symlink_twice/__test__.jsonc b/tests/specs/compile/include/symlink_twice/__test__.jsonc new file mode 100644 index 00000000000000..ebdf824f43cf84 --- /dev/null +++ b/tests/specs/compile/include/symlink_twice/__test__.jsonc @@ -0,0 +1,27 @@ +{ + "tempDir": true, + "steps": [{ + "args": "run -A setup.js", + "output": "[WILDCARD]" + }, { + "if": "unix", + "args": "compile --allow-read=data --include . --output main link.js", + "output": "[WILDCARD]" + }, { + "if": "unix", + "commandName": "./main", + "args": [], + "output": "1\n", + "exitCode": 0 + }, { + "if": "windows", + "args": "compile --allow-read=data --include . --output main.exe link.js", + "output": "[WILDCARD]" + }, { + "if": "windows", + "commandName": "./main.exe", + "args": [], + "output": "1\n", + "exitCode": 0 + }] +} diff --git a/tests/specs/compile/include/symlink_twice/setup.js b/tests/specs/compile/include/symlink_twice/setup.js new file mode 100644 index 00000000000000..3e713dd63e918a --- /dev/null +++ b/tests/specs/compile/include/symlink_twice/setup.js @@ -0,0 +1,3 @@ +Deno.mkdirSync("data"); +Deno.writeTextFileSync("index.js", "console.log(1);"); +Deno.symlinkSync("index.js", "link.js");