@henryqw/pi-herdr 0.1.3 → 0.2.0
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/dist/index.d.ts +2 -0
- package/dist/index.js +11 -0
- package/package.json +7 -1
package/dist/index.d.ts
CHANGED
|
@@ -13,3 +13,5 @@ export interface HerdrClient<Options> {
|
|
|
13
13
|
export declare function createHerdrClient<Options>(execute: HerdrExecutor<Options>): HerdrClient<Options>;
|
|
14
14
|
export declare function herdrCommandFailure(args: readonly string[], result: HerdrExecResult): string;
|
|
15
15
|
export declare function hasHerdrErrorCode(result: Pick<HerdrExecResult, "stdout" | "stderr">, expected: string): boolean;
|
|
16
|
+
/** Lock a Herdr worktree checkout path while mutating it via the Herdr CLI. */
|
|
17
|
+
export declare function withWorktreeLock<T>(checkout: string, operation: () => Promise<T>): Promise<T>;
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { lock } from "proper-lockfile";
|
|
1
2
|
export function createHerdrClient(execute) {
|
|
2
3
|
const exec = async (args, options) => {
|
|
3
4
|
if (!Array.isArray(args) || args.some((arg) => typeof arg !== "string")) {
|
|
@@ -42,6 +43,16 @@ export function hasHerdrErrorCode(result, expected) {
|
|
|
42
43
|
}
|
|
43
44
|
});
|
|
44
45
|
}
|
|
46
|
+
/** Lock a Herdr worktree checkout path while mutating it via the Herdr CLI. */
|
|
47
|
+
export async function withWorktreeLock(checkout, operation) {
|
|
48
|
+
const release = await lock(checkout);
|
|
49
|
+
try {
|
|
50
|
+
return await operation();
|
|
51
|
+
}
|
|
52
|
+
finally {
|
|
53
|
+
await release();
|
|
54
|
+
}
|
|
55
|
+
}
|
|
45
56
|
function herdrCommandName(args) {
|
|
46
57
|
return ["herdr", ...args.slice(0, 2)].join(" ");
|
|
47
58
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@henryqw/pi-herdr",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Shared client for interacting with Herdr from Node.js tools and Pi packages.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pi-package",
|
|
@@ -32,6 +32,12 @@
|
|
|
32
32
|
"prepack": "npm run build",
|
|
33
33
|
"pack:check": "npm pack --dry-run"
|
|
34
34
|
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"@types/proper-lockfile": "^4.1.4"
|
|
37
|
+
},
|
|
38
|
+
"dependencies": {
|
|
39
|
+
"proper-lockfile": "^4.1.2"
|
|
40
|
+
},
|
|
35
41
|
"repository": {
|
|
36
42
|
"type": "git",
|
|
37
43
|
"url": "git+https://github.com/HenryQW/pi-packages.git",
|