Skip to content

Commit 9bc27b7

Browse files
authored
fix: dont point to 404 in config schema (#339)
1 parent 8519fc6 commit 9bc27b7

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

crates/pgt_workspace/src/configuration.rs

+7-6
Original file line numberDiff line numberDiff line change
@@ -170,12 +170,13 @@ pub fn create_config(
170170
})?;
171171

172172
// we now check if postgrestools is installed inside `node_modules` and if so, we use the schema from there
173-
if VERSION == "0.0.0" {
174-
let schema_path = Path::new("./node_modules/@postgrestools/postgrestools/schema.json");
175-
let options = OpenOptions::default().read(true);
176-
if fs.open_with_options(schema_path, options).is_ok() {
177-
configuration.schema = schema_path.to_str().map(String::from);
178-
}
173+
let node_schema_path = Path::new("./node_modules/@postgrestools/postgrestools/schema.json");
174+
let options = OpenOptions::default().read(true);
175+
if fs.open_with_options(node_schema_path, options).is_ok() {
176+
configuration.schema = node_schema_path.to_str().map(String::from);
177+
} else if VERSION == "0.0.0" {
178+
// VERSION is 0.0.0 if it has not been explicitly set (e.g local dev, as fallback)
179+
configuration.schema = Some("https://pgtools.dev/schemas/latest/schema.json".to_string());
179180
} else {
180181
configuration.schema = Some(format!("https://pgtools.dev/schemas/{VERSION}/schema.json"));
181182
}

0 commit comments

Comments
 (0)