Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@

#### :nail_care: Polish

- Read package name from rescript.json if package.json is absent. https://github.com/rescript-lang/rescript/pull/7746

#### :house: Internal

- Add token viewer to `res_parser`. https://github.com/rescript-lang/rescript/pull/7751
Expand Down
8 changes: 6 additions & 2 deletions rewatch/src/build/packages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -399,8 +399,12 @@ fn flatten_dependencies(dependencies: Vec<Dependency>) -> Vec<Dependency> {
pub fn read_package_name(package_dir: &Path) -> Result<String> {
let package_json_path = package_dir.join("package.json");

let package_json_contents =
fs::read_to_string(&package_json_path).map_err(|e| anyhow!("Could not read package.json: {}", e))?;
let package_json_contents = if Path::exists(&package_json_path) {
fs::read_to_string(&package_json_path).map_err(|e| anyhow!("Could not read package.json: {}", e))?
} else {
let rescript_json_path = package_dir.join("rescript.json");
fs::read_to_string(&rescript_json_path).map_err(|e| anyhow!("Could not read rescript.json: {}", e))?
};

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