mirror of
https://github.com/pesde-pkg/pesde.git
synced 2024-12-12 11:00:36 +00:00
fix: do not require -- in bin executables on unix
This commit is contained in:
parent
ac74c57709
commit
5513ef41a3
3 changed files with 29 additions and 12 deletions
|
@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
- Link dependencies before type extraction to support more use cases by @daimond113
|
- Link dependencies before type extraction to support more use cases by @daimond113
|
||||||
- Strip `.luau` extension from linker modules' require paths to comply with Luau by @daimond113
|
- Strip `.luau` extension from linker modules' require paths to comply with Luau by @daimond113
|
||||||
- Correctly handle graph paths for resolving overriden packages by @daimond113
|
- Correctly handle graph paths for resolving overriden packages by @daimond113
|
||||||
|
- Do not require `--` in bin package executables on Unix by @daimond113
|
||||||
|
|
||||||
## [0.5.0-rc.14] - 2024-11-30
|
## [0.5.0-rc.14] - 2024-11-30
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
|
@ -45,12 +45,8 @@ fn bin_link_file(alias: &str) -> String {
|
||||||
.collect::<Vec<_>>()
|
.collect::<Vec<_>>()
|
||||||
.join(", ");
|
.join(", ");
|
||||||
|
|
||||||
#[cfg(not(unix))]
|
|
||||||
let prefix = String::new();
|
|
||||||
#[cfg(unix)]
|
|
||||||
let prefix = "#!/usr/bin/env -S lune run\n";
|
|
||||||
format!(
|
format!(
|
||||||
r#"{prefix}local process = require("@lune/process")
|
r#"local process = require("@lune/process")
|
||||||
local fs = require("@lune/fs")
|
local fs = require("@lune/fs")
|
||||||
local stdio = require("@lune/stdio")
|
local stdio = require("@lune/stdio")
|
||||||
|
|
||||||
|
@ -234,27 +230,42 @@ impl InstallCommand {
|
||||||
.map(|alias| {
|
.map(|alias| {
|
||||||
let bin_folder = bin_folder.clone();
|
let bin_folder = bin_folder.clone();
|
||||||
async move {
|
async move {
|
||||||
let bin_file = bin_folder.join(alias);
|
let bin_exec_file = bin_folder.join(alias).with_extension(std::env::consts::EXE_EXTENSION);
|
||||||
|
|
||||||
|
let impl_folder = bin_folder.join(".impl");
|
||||||
|
fs::create_dir_all(&impl_folder).await.context("failed to create bin link folder")?;
|
||||||
|
|
||||||
|
let bin_file = impl_folder.join(alias).with_extension("luau");
|
||||||
fs::write(&bin_file, bin_link_file(alias))
|
fs::write(&bin_file, bin_link_file(alias))
|
||||||
.await
|
.await
|
||||||
.context("failed to write bin link file")?;
|
.context("failed to write bin link file")?;
|
||||||
|
|
||||||
make_executable(&bin_file)
|
|
||||||
.await
|
|
||||||
.context("failed to make bin link executable")?;
|
|
||||||
|
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
{
|
{
|
||||||
let bin_file = bin_file.with_extension(std::env::consts::EXE_EXTENSION);
|
|
||||||
fs::copy(
|
fs::copy(
|
||||||
std::env::current_exe()
|
std::env::current_exe()
|
||||||
.context("failed to get current executable path")?,
|
.context("failed to get current executable path")?,
|
||||||
&bin_file,
|
&bin_exec_file,
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
.context("failed to copy bin link file")?;
|
.context("failed to copy bin link file")?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(not(windows))]
|
||||||
|
{
|
||||||
|
fs::write(
|
||||||
|
&bin_exec_file,
|
||||||
|
format!(r#"#!/bin/sh
|
||||||
|
lune run "$(dirname "$0")/.impl/{alias}.luau" -- "$@""#
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
.context("failed to link bin link file")?;
|
||||||
|
}
|
||||||
|
|
||||||
|
make_executable(&bin_exec_file).await.context("failed to make bin link file executable")?;
|
||||||
|
|
||||||
Ok::<_, CallbackError>(())
|
Ok::<_, CallbackError>(())
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
|
|
|
@ -114,7 +114,12 @@ async fn run() -> anyhow::Result<()> {
|
||||||
// on unix systems
|
// on unix systems
|
||||||
let status = std::process::Command::new("lune")
|
let status = std::process::Command::new("lune")
|
||||||
.arg("run")
|
.arg("run")
|
||||||
.arg(exe.with_extension(""))
|
.arg(
|
||||||
|
exe.parent()
|
||||||
|
.map(|p| p.join(".impl").join(exe.file_name().unwrap()))
|
||||||
|
.unwrap_or(exe)
|
||||||
|
.with_extension("luau"),
|
||||||
|
)
|
||||||
.arg("--")
|
.arg("--")
|
||||||
.args(std::env::args_os().skip(1))
|
.args(std::env::args_os().skip(1))
|
||||||
.current_dir(cwd)
|
.current_dir(cwd)
|
||||||
|
|
Loading…
Reference in a new issue