mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 18:47:45 +02:00
Fix cd'ing to symlinked directories (#1651)
* fix: absolutize path against its parent if it was a symlink. On Linux this happens because Rust calls readlink but doesn't canonicalize the resultant path. * feat: playground function to create symlinks * fix: use playground dirs * feat: test for #1631, shift tests names
This commit is contained in:
committed by
GitHub
parent
e7a4f31b38
commit
846a779516
@ -95,6 +95,33 @@ impl Playground {
|
||||
self
|
||||
}
|
||||
|
||||
pub fn symlink(&mut self, from: impl AsRef<Path>, to: impl AsRef<Path>) -> &mut Self {
|
||||
let from = self.cwd.join(from);
|
||||
let to = self.cwd.join(to);
|
||||
|
||||
let create_symlink = {
|
||||
#[cfg(unix)]
|
||||
{
|
||||
std::os::unix::fs::symlink
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
{
|
||||
if from.is_file() {
|
||||
std::os::windows::fs::symlink_file
|
||||
} else if from.is_dir() {
|
||||
std::os::windows::fs::symlink_dir
|
||||
} else {
|
||||
panic!("symlink from must be a file or dir")
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
create_symlink(from, to).expect("can not create symlink");
|
||||
self.back_to_playground();
|
||||
self
|
||||
}
|
||||
|
||||
pub fn with_files(&mut self, files: Vec<Stub>) -> &mut Self {
|
||||
let endl = fs::line_ending();
|
||||
|
||||
|
Reference in New Issue
Block a user