Skip to content

Commit

Permalink
Move node-executor reading of .nvmrc to compile time (#23908)
Browse files Browse the repository at this point in the history
This allows us to precompile on one machine and run on another without a
checkout.

GitOrigin-RevId: 37a359a84c211a5c3f04d1f350bd7b24f34fdf99
  • Loading branch information
nipunn1313 authored and Convex, Inc. committed Mar 25, 2024
1 parent acec008 commit b0de598
Showing 1 changed file with 6 additions and 15 deletions.
21 changes: 6 additions & 15 deletions crates/node_executor/src/local.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
use std::{
fs,
path::{
Path,
PathBuf,
},
path::PathBuf,
time::Duration,
};

Expand Down Expand Up @@ -34,6 +31,10 @@ use crate::executor::{
EXECUTE_TIMEOUT_RESPONSE_JSON,
};

/// Always use node version specified in .nvmrc for lambda execution, even if
/// we're using older version for CLI.
const NODE_VERSION: &str = include_str!("../../../.nvmrc");

pub struct LocalNodeExecutor {
_source_dir: TempDir,
source_path: PathBuf,
Expand All @@ -57,17 +58,7 @@ impl LocalNodeExecutor {
"Using local node executor. Source: {}",
source_path.to_str().expect("Path is not UTF-8 string?"),
);
let repo_root = Path::new(env!("CARGO_MANIFEST_DIR"))
.parent()
.unwrap()
.parent()
.unwrap();

// Always use node version specified in .nvmrc for lambda execution, even if
// we're using older version for CLI.
let node_version = fs::read_to_string(repo_root.join(".nvmrc"))?
.trim()
.to_string();
let node_version = NODE_VERSION.trim();

// Look for node16 in a few places. CI nvm installer uses `mynvm`
let mut node_path = "node".to_string();
Expand Down

0 comments on commit b0de598

Please sign in to comment.