Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
a bit better
  • Loading branch information
psteinroe committed Apr 15, 2025
commit a24eefa525effd36cc93ecebd50975397d005235
10 changes: 6 additions & 4 deletions crates/pgt_workspace/src/configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,12 +170,14 @@ pub fn create_config(
})?;

// we now check if postgrestools is installed inside `node_modules` and if so, we use the schema from there
let schema_path = Path::new("./node_modules/@postgrestools/postgrestools/schema.json");
let node_schema_path = Path::new("./node_modules/@postgrestools/postgrestools/schema.json");
let options = OpenOptions::default().read(true);
if fs.open_with_options(schema_path, options).is_ok() {
configuration.schema = schema_path.to_str().map(String::from);
} else {
if fs.open_with_options(node_schema_path, options).is_ok() {
configuration.schema = node_schema_path.to_str().map(String::from);
} else if VERSION == "0.0.0" {
configuration.schema = Some("https://pgtools.dev/schemas/latest/schema.json".to_string());
} else {
configuration.schema = Some(format!("https://pgtools.dev/schemas/{VERSION}/schema.json"));
}

let contents = serde_json::to_string_pretty(&configuration)
Expand Down
Loading