Skip to content

Commit

Permalink
new: Use pnpm-deduplicate for pnpm deduping. (#501)
Browse files Browse the repository at this point in the history
* Use package.

* Update changelog.
  • Loading branch information
milesj committed Dec 19, 2022
1 parent f206121 commit e7bd899
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 25 deletions.
16 changes: 6 additions & 10 deletions crates/core/toolchain/src/tools/pnpm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,18 +99,14 @@ impl DependencyManager<NodeTool> for PnpmTool {

async fn dedupe_dependencies(
&self,
_node: &NodeTool,
_working_dir: &Path,
node: &NodeTool,
working_dir: &Path,
_log: bool,
) -> Result<(), ToolchainError> {
// pnpm doesn't support deduping, but maybe prune is good here?
// https://pnpm.io/cli/prune
// self.create_command(node)
// .arg("prune")
// .cwd(working_dir)
// .log_running_command(log)
// .exec_capture_output()
// .await?;
if working_dir.join(self.get_lock_filename()).exists() {
node.exec_package("pnpm-deduplicate", &["pnpm-deduplicate"], working_dir)
.await?;
}

Ok(())
}
Expand Down
21 changes: 7 additions & 14 deletions crates/node/platform/src/actions/install_deps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,24 +213,17 @@ pub async fn install_deps(
// dedupe
if !is_ci() && node.config.dedupe_on_lockfile_change {
let dedupe_command = match node.config.package_manager {
NodePackageManager::Npm => Some("npm dedupe"),
NodePackageManager::Pnpm => None,
NodePackageManager::Yarn => Some("yarn dedupe"),
NodePackageManager::Npm => "npm dedupe",
NodePackageManager::Pnpm => "pnpm dedupe",
NodePackageManager::Yarn => "yarn dedupe",
};

if let Some(dedupe_command) = dedupe_command {
debug!(target: LOG_TARGET, "Deduping dependencies");
debug!(target: LOG_TARGET, "Deduping dependencies");

print_checkpoint(dedupe_command, Checkpoint::Setup);
print_checkpoint(dedupe_command, Checkpoint::Setup);

pm.dedupe_dependencies(node, &working_dir, should_log_command)
.await?;
} else {
debug!(
target: LOG_TARGET,
"Skipping deduping dependencies, not available for current package manager"
);
}
pm.dedupe_dependencies(node, &working_dir, should_log_command)
.await?;
}

// Update the cache with the timestamp
Expand Down
5 changes: 4 additions & 1 deletion packages/cli/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
- Added `args` and `env` as valid values for the `affectedFiles` task option.
- Updated `moon run` and `moon query touched-files` to support a list of `--status` options.
- Updated the system platform to include the operating system and architecture when hashing.
- Updated pnpm prune to use the [pnpm-deduplicate](https://www.npmjs.com/package/pnpm-deduplicate)
package.

##### Toolchain

Expand All @@ -29,7 +31,8 @@
#### 🐞 Fixes

- Fixed an issue where "installing yarn" would constantly show.
- Fixed an issue on Windows where `package.json` and `tsconfig.json` would change newlines unexpectedly when saving.
- Fixed an issue on Windows where `package.json` and `tsconfig.json` would change newlines
unexpectedly when saving.

## 0.20.3

Expand Down

0 comments on commit e7bd899

Please sign in to comment.