Skip to content

Commit

Permalink
fix(compile): do not error embedding same symlink via multiple methods (
Browse files Browse the repository at this point in the history
#27015)

Closes #27012
  • Loading branch information
dsherret authored Nov 25, 2024
1 parent 7456255 commit 02b480b
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 2 deletions.
4 changes: 2 additions & 2 deletions cli/standalone/virtual_fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -341,9 +341,9 @@ impl VfsBuilder {
.collect::<Vec<_>>(),
}),
);
Ok(())
}
}
Ok(())
}

pub fn into_dir_and_files(self) -> (VirtualDirectory, Vec<Vec<u8>>) {
Expand Down
27 changes: 27 additions & 0 deletions tests/specs/compile/include/symlink_twice/__test__.jsonc
Original file line number Diff line number Diff line change
@@ -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
}]
}
3 changes: 3 additions & 0 deletions tests/specs/compile/include/symlink_twice/setup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Deno.mkdirSync("data");
Deno.writeTextFileSync("index.js", "console.log(1);");
Deno.symlinkSync("index.js", "link.js");

0 comments on commit 02b480b

Please sign in to comment.