@pnpm/network.git-utils 1100.0.0 → 1100.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/lib/index.d.ts +7 -4
- package/lib/index.js +8 -9
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
# @pnpm/git-utils
|
|
1
|
+
# @pnpm/network.git-utils
|
|
2
2
|
|
|
3
3
|
> Utilities for git
|
|
4
4
|
|
|
5
5
|
<!--@shields('npm')-->
|
|
6
|
-
[](https://
|
|
6
|
+
[](https://npmx.dev/package/@pnpm/network.git-utils)
|
|
7
7
|
<!--/@-->
|
|
8
8
|
|
|
9
9
|
## Installation
|
|
10
10
|
|
|
11
11
|
```
|
|
12
|
-
pnpm add @pnpm/git-utils
|
|
12
|
+
pnpm add @pnpm/network.git-utils
|
|
13
13
|
```
|
|
14
14
|
|
|
15
15
|
## Usage
|
package/lib/index.d.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export declare function
|
|
1
|
+
export interface GitCwdOptions {
|
|
2
|
+
cwd?: string;
|
|
3
|
+
}
|
|
4
|
+
export declare function isGitRepo(opts?: GitCwdOptions): Promise<boolean>;
|
|
5
|
+
export declare function getCurrentBranch(opts?: GitCwdOptions): Promise<string | null>;
|
|
6
|
+
export declare function isWorkingTreeClean(opts?: GitCwdOptions): Promise<boolean>;
|
|
7
|
+
export declare function isRemoteHistoryClean(opts?: GitCwdOptions): Promise<boolean>;
|
package/lib/index.js
CHANGED
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
import { safeExeca as execa } from 'execa';
|
|
2
|
-
|
|
3
|
-
export async function isGitRepo() {
|
|
2
|
+
export async function isGitRepo(opts = {}) {
|
|
4
3
|
try {
|
|
5
|
-
await execa('git', ['rev-parse', '--git-dir']);
|
|
4
|
+
await execa('git', ['rev-parse', '--git-dir'], { cwd: opts.cwd });
|
|
6
5
|
}
|
|
7
6
|
catch {
|
|
8
7
|
return false;
|
|
9
8
|
}
|
|
10
9
|
return true;
|
|
11
10
|
}
|
|
12
|
-
export async function getCurrentBranch() {
|
|
11
|
+
export async function getCurrentBranch(opts = {}) {
|
|
13
12
|
try {
|
|
14
|
-
const { stdout } = await execa('git', ['symbolic-ref', '--short', 'HEAD']);
|
|
13
|
+
const { stdout } = await execa('git', ['symbolic-ref', '--short', 'HEAD'], { cwd: opts.cwd });
|
|
15
14
|
return stdout;
|
|
16
15
|
}
|
|
17
16
|
catch {
|
|
@@ -19,9 +18,9 @@ export async function getCurrentBranch() {
|
|
|
19
18
|
return null;
|
|
20
19
|
}
|
|
21
20
|
}
|
|
22
|
-
export async function isWorkingTreeClean() {
|
|
21
|
+
export async function isWorkingTreeClean(opts = {}) {
|
|
23
22
|
try {
|
|
24
|
-
const { stdout: status } = await execa('git', ['status', '--porcelain']);
|
|
23
|
+
const { stdout: status } = await execa('git', ['status', '--porcelain'], { cwd: opts.cwd });
|
|
25
24
|
if (status !== '') {
|
|
26
25
|
return false;
|
|
27
26
|
}
|
|
@@ -31,10 +30,10 @@ export async function isWorkingTreeClean() {
|
|
|
31
30
|
return false;
|
|
32
31
|
}
|
|
33
32
|
}
|
|
34
|
-
export async function isRemoteHistoryClean() {
|
|
33
|
+
export async function isRemoteHistoryClean(opts = {}) {
|
|
35
34
|
let history;
|
|
36
35
|
try { // Gracefully handle no remote set up.
|
|
37
|
-
const { stdout } = await execa('git', ['rev-list', '--count', '--left-only', '@{u}...HEAD']);
|
|
36
|
+
const { stdout } = await execa('git', ['rev-list', '--count', '--left-only', '@{u}...HEAD'], { cwd: opts.cwd });
|
|
38
37
|
history = stdout;
|
|
39
38
|
}
|
|
40
39
|
catch {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pnpm/network.git-utils",
|
|
3
|
-
"version": "1100.0.
|
|
3
|
+
"version": "1100.0.1",
|
|
4
4
|
"description": "Utilities for git",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pnpm",
|
|
@@ -29,8 +29,9 @@
|
|
|
29
29
|
"execa": "npm:safe-execa@0.3.0"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
+
"@jest/globals": "30.3.0",
|
|
32
33
|
"tempy": "3.0.0",
|
|
33
|
-
"@pnpm/network.git-utils": "1100.0.
|
|
34
|
+
"@pnpm/network.git-utils": "1100.0.1"
|
|
34
35
|
},
|
|
35
36
|
"engines": {
|
|
36
37
|
"node": ">=22.13"
|