mirror of
https://github.com/lune-org/lune.git
synced 2024-12-12 13:00:37 +00:00
De-UNC file paths on windows wherever possible
This commit is contained in:
parent
ec040e420e
commit
eecffca741
5 changed files with 17 additions and 6 deletions
|
@ -25,6 +25,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
- Improved accuracy of Selene type definitions, strongly typed arrays are now used where possible
|
||||
- Improve error handling and messages for `net.serve`
|
||||
- Improve error handling and messages for `stdio.prompt`
|
||||
- File path representations on Windows now use legacy paths instead of UNC paths wherever possible, preventing some confusing cases where file paths don't work as expected
|
||||
|
||||
### Fixed
|
||||
|
||||
|
|
7
Cargo.lock
generated
7
Cargo.lock
generated
|
@ -307,6 +307,12 @@ dependencies = [
|
|||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "dunce"
|
||||
version = "1.0.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0bd4b30a6560bbd9b4620f4de34c3f14f60848e58a9b7216801afcb4c7b31c3c"
|
||||
|
||||
[[package]]
|
||||
name = "encode_unicode"
|
||||
version = "0.3.6"
|
||||
|
@ -786,6 +792,7 @@ dependencies = [
|
|||
"console",
|
||||
"dialoguer",
|
||||
"directories",
|
||||
"dunce",
|
||||
"futures-util",
|
||||
"hyper",
|
||||
"hyper-tungstenite",
|
||||
|
|
|
@ -34,6 +34,7 @@ hyper = { version = "0.14.24", features = ["full"] }
|
|||
hyper-tungstenite = { version = "0.9.0" }
|
||||
tokio-tungstenite = { version = "0.18.0" }
|
||||
mlua = { version = "0.8.7", features = ["luau", "serialize"] }
|
||||
dunce = "1.0.3"
|
||||
|
||||
[dev-dependencies]
|
||||
anyhow = "1.0.69"
|
||||
|
|
|
@ -6,6 +6,7 @@ use std::{
|
|||
};
|
||||
|
||||
use directories::UserDirs;
|
||||
use dunce::canonicalize;
|
||||
use mlua::prelude::*;
|
||||
use os_str_bytes::RawOsString;
|
||||
use tokio::process::Command;
|
||||
|
@ -21,7 +22,7 @@ yield()
|
|||
|
||||
pub fn create(lua: &'static Lua, args_vec: Vec<String>) -> LuaResult<LuaTable> {
|
||||
let cwd_str = {
|
||||
let cwd = env::current_dir()?.canonicalize()?;
|
||||
let cwd = canonicalize(env::current_dir()?)?;
|
||||
let cwd_str = cwd.to_string_lossy().to_string();
|
||||
if !cwd_str.ends_with(path::MAIN_SEPARATOR) {
|
||||
format!("{cwd_str}{}", path::MAIN_SEPARATOR)
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
use std::{
|
||||
env::{self, current_dir},
|
||||
fs,
|
||||
path::PathBuf,
|
||||
path::{self, PathBuf},
|
||||
};
|
||||
|
||||
use dunce::canonicalize;
|
||||
use mlua::prelude::*;
|
||||
|
||||
use crate::lua::table::TableBuilder;
|
||||
|
@ -35,8 +36,8 @@ pub fn create(lua: &'static Lua) -> LuaResult<LuaTable> {
|
|||
}
|
||||
// Store the current pwd, and make the functions for path conversions & loading a file
|
||||
let mut require_pwd = current_dir()?.to_string_lossy().to_string();
|
||||
if !require_pwd.ends_with('/') {
|
||||
require_pwd = format!("{require_pwd}/")
|
||||
if !require_pwd.ends_with(path::MAIN_SEPARATOR) {
|
||||
require_pwd = format!("{require_pwd}{}", path::MAIN_SEPARATOR)
|
||||
}
|
||||
let require_info: LuaFunction = lua.named_registry_value("dbg.info")?;
|
||||
let require_error: LuaFunction = lua.named_registry_value("error")?;
|
||||
|
@ -53,8 +54,8 @@ pub fn create(lua: &'static Lua) -> LuaResult<LuaTable> {
|
|||
.join(&require_path);
|
||||
// Try to normalize and resolve relative path segments such as './' and '../'
|
||||
let file_path = match (
|
||||
path_relative_to_pwd.with_extension("luau").canonicalize(),
|
||||
path_relative_to_pwd.with_extension("lua").canonicalize(),
|
||||
canonicalize(path_relative_to_pwd.with_extension("luau")),
|
||||
canonicalize(path_relative_to_pwd.with_extension("lua")),
|
||||
) {
|
||||
(Ok(luau), _) => luau,
|
||||
(_, Ok(lua)) => lua,
|
||||
|
|
Loading…
Reference in a new issue