Skip to content

Commit

Permalink
chore(cli): slightly improve code and test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
felipeplets committed Jul 3, 2024
1 parent 713f5b7 commit 54282a8
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions packages/cli/src/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,12 @@ function formatFilepath(filepath) {
export function getSiblings(root) {
const siblings = [path.join(root, '..')];

// if we're in a pnpm package, add the root of the workspace node_modules to the list of siblings
if (root.includes('.pnpm')) {
// Find the index of the first occurrence of '.pnpm'
const nodeModulesIndex = root.indexOf('.pnpm');

// If 'node_modules' is found, extract the substring up to that point
if (nodeModulesIndex !== -1) {
siblings.push(path.join(root.substring(0, nodeModulesIndex), '@percy'));
}
// Check if Percy CLI is installed using '.pnpm' by searching
// ffor the .pnpm folder in the root path
const nodeModulesIndex = root.indexOf('.pnpm');
if (nodeModulesIndex !== -1) {
// add the parent directory of the .pnpm and append /@percy
siblings.push(path.join(root.substring(0, nodeModulesIndex), '@percy'));
}

return siblings;
Expand Down

0 comments on commit 54282a8

Please sign in to comment.