Skip to content

Commit

Permalink
fix: bin path ordering
Browse files Browse the repository at this point in the history
  • Loading branch information
guybedford committed Mar 23, 2023
1 parent 0786c7b commit beae8c1
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 25 deletions.
36 changes: 14 additions & 22 deletions src/engines/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,33 +139,25 @@ impl<'a> CmdPool<'a> {
cwd: String,
extension_env: &'a mut ExtensionEnvironment,
) -> CmdPool<'a> {
let mut path: String = env::var("PATH").unwrap_or_default();
#[cfg(not(target_os = "windows"))]
if path.len() > 0 && !path.ends_with(':') {
path += ":";
}
#[cfg(target_os = "windows")]
if path.len() > 0 && !path.ends_with(';') {
path += ";";
}
path.push_str(&cwd);
#[cfg(not(target_os = "windows"))]
{
let path = {
let mut path = String::from(&cwd);
path += "/.bin:";
}
#[cfg(target_os = "windows")]
{
path += "\\.bin;";
}
path.push_str(&cwd);
#[cfg(not(target_os = "windows"))]
{
path.push_str(&cwd);
path += "/node_modules/.bin";
}
path += ":";
path.push_str(&env::var("PATH").unwrap_or_default());
path
};
#[cfg(target_os = "windows")]
{
let path = {
let mut path = cwd.replace('/', "\\");
path += "\\.bin;";
path.push_str(&cwd.replace('/', "\\"));
path += "\\node_modules\\.bin;";
}
path.push_str(&env::var("PATH").unwrap_or_default());
path
};
CmdPool {
cmd_num: 0,
cwd,
Expand Down
2 changes: 1 addition & 1 deletion src/engines/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ use crate::engines::create_cmd;
use crate::engines::CmdPool;
use crate::engines::Exec;
use crate::engines::{BatchCmd, ExecState};
use base64::{engine::general_purpose, Engine as _};
use futures::future::FutureExt;
use percent_encoding::percent_encode;
use percent_encoding::NON_ALPHANUMERIC;
use std::time::Instant;
use base64::{engine::general_purpose, Engine as _};

// Custom node loader to mimic current working directory despite loading from a tmp file
// Note: We dont have to percent encode as we're not using `,! characters
Expand Down
4 changes: 2 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ fn uri_parse(uri_str: &str) -> Option<Uri> {
#[tokio::main]
async fn main() -> Result<()> {
#[cfg(not(debug_assertions))]
let version = "0.2.13";
let version = "0.2.14";
#[cfg(debug_assertions)]
let version = "0.2.13-debug";
let version = "0.2.14-debug";
let matches = Command::new("Chomp")
.version(version)
.arg(
Expand Down

0 comments on commit beae8c1

Please sign in to comment.