Skip to content

Commit

Permalink
Remove dependency on current-git-branch (#335)
Browse files Browse the repository at this point in the history
  • Loading branch information
askoufis committed Mar 4, 2024
1 parent 134c5a4 commit cad1ded
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 70 deletions.
5 changes: 5 additions & 0 deletions .changeset/breezy-monkeys-cough.md
@@ -0,0 +1,5 @@
---
'playroom': patch
---

Remove dependency on `current-git-branch` package
15 changes: 13 additions & 2 deletions lib/provideDefaultConfig.js
@@ -1,10 +1,21 @@
const readPackage = require('read-pkg-up');
const currentGitBranch = require('current-git-branch');
const { execSync } = require('child_process');

/**
* @returns {string | null} The current git branch name, or null if no branch is found
*/
const getGitBranch = () => {
try {
return execSync('git branch --show-current').toString().trim();
} catch (e) {
return null;
}
};

const generateStorageKey = () => {
const pkg = readPackage.sync();
const packageName = (pkg && pkg.packageJson && pkg.packageJson.name) || null;
const branchName = currentGitBranch();
const branchName = getGitBranch();

const packageLabel = packageName ? `package:${packageName}` : null;
const branchLabel = branchName ? `branch:${branchName}` : null;
Expand Down
1 change: 0 additions & 1 deletion package.json
Expand Up @@ -79,7 +79,6 @@
"command-line-usage": "^6.1.3",
"copy-to-clipboard": "^3.3.3",
"css-loader": "^6.7.2",
"current-git-branch": "^1.1.0",
"dedent": "^1.5.1",
"fast-glob": "^3.2.12",
"find-up": "^5.0.0",
Expand Down
74 changes: 7 additions & 67 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit cad1ded

Please sign in to comment.