Skip to content

Commit 400ebbc

Browse files
committed
Try and read package name from rescript.json if package.json is not present.
1 parent 2aee2fd commit 400ebbc

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

rewatch/src/build/packages.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -399,8 +399,12 @@ fn flatten_dependencies(dependencies: Vec<Dependency>) -> Vec<Dependency> {
399399
pub fn read_package_name(package_dir: &Path) -> Result<String> {
400400
let package_json_path = package_dir.join("package.json");
401401

402-
let package_json_contents =
403-
fs::read_to_string(&package_json_path).map_err(|e| anyhow!("Could not read package.json: {}", e))?;
402+
let package_json_contents = if Path::exists(&package_json_path) {
403+
fs::read_to_string(&package_json_path).map_err(|e| anyhow!("Could not read package.json: {}", e))?
404+
} else {
405+
let rescript_json_path = package_dir.join("rescript.json");
406+
fs::read_to_string(&rescript_json_path).map_err(|e| anyhow!("Could not read rescript.json: {}", e))?
407+
};
404408

405409
let package_json: serde_json::Value = serde_json::from_str(&package_json_contents)
406410
.map_err(|e| anyhow!("Could not parse package.json: {}", e))?;

0 commit comments

Comments
 (0)