type-git 0.1.0 → 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/adapters/bun/index.cjs +21 -2
- package/dist/adapters/bun/index.cjs.map +1 -1
- package/dist/adapters/bun/index.d.cts +1 -1
- package/dist/adapters/bun/index.d.ts +1 -1
- package/dist/adapters/bun/index.js +21 -2
- package/dist/adapters/bun/index.js.map +1 -1
- package/dist/adapters/deno/index.cjs +29 -2
- package/dist/adapters/deno/index.cjs.map +1 -1
- package/dist/adapters/deno/index.d.cts +1 -1
- package/dist/adapters/deno/index.d.ts +1 -1
- package/dist/adapters/deno/index.js +29 -2
- package/dist/adapters/deno/index.js.map +1 -1
- package/dist/adapters/node/index.cjs +37 -8
- package/dist/adapters/node/index.cjs.map +1 -1
- package/dist/adapters/node/index.d.cts +1 -1
- package/dist/adapters/node/index.d.ts +1 -1
- package/dist/adapters/node/index.js +37 -8
- package/dist/adapters/node/index.js.map +1 -1
- package/dist/{adapters-DehG3CsV.d.cts → adapters-BFRtEriX.d.cts} +37 -2
- package/dist/{adapters-DehG3CsV.d.ts → adapters-BFRtEriX.d.ts} +37 -2
- package/dist/index.cjs +37 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +37 -8
- package/dist/index.js.map +1 -1
- package/package.json +2 -1
|
@@ -433,8 +433,25 @@ type StreamHandler = {
|
|
|
433
433
|
* Handle to a spawned process
|
|
434
434
|
*
|
|
435
435
|
* Allows streaming output and waiting for completion.
|
|
436
|
+
* Implements AsyncDisposable for use with `await using`.
|
|
437
|
+
*
|
|
438
|
+
* @example
|
|
439
|
+
* ```typescript
|
|
440
|
+
* // Traditional usage
|
|
441
|
+
* const handle = adapter.spawnStreaming({ argv: ['git', 'fetch'] });
|
|
442
|
+
* try {
|
|
443
|
+
* for await (const line of handle.stdout) { console.log(line); }
|
|
444
|
+
* } finally {
|
|
445
|
+
* handle.kill();
|
|
446
|
+
* }
|
|
447
|
+
*
|
|
448
|
+
* // With await using (recommended)
|
|
449
|
+
* await using handle = adapter.spawnStreaming({ argv: ['git', 'fetch'] });
|
|
450
|
+
* for await (const line of handle.stdout) { console.log(line); }
|
|
451
|
+
* // Automatically disposed when scope exits
|
|
452
|
+
* ```
|
|
436
453
|
*/
|
|
437
|
-
interface SpawnHandle {
|
|
454
|
+
interface SpawnHandle extends AsyncDisposable {
|
|
438
455
|
/** Async iterator for stdout lines */
|
|
439
456
|
readonly stdout: AsyncIterable<string>;
|
|
440
457
|
/** Async iterator for stderr lines */
|
|
@@ -487,8 +504,26 @@ type TailOptions = {
|
|
|
487
504
|
};
|
|
488
505
|
/**
|
|
489
506
|
* Handle to a tail operation
|
|
507
|
+
*
|
|
508
|
+
* Implements AsyncDisposable for use with `await using`.
|
|
509
|
+
*
|
|
510
|
+
* @example
|
|
511
|
+
* ```typescript
|
|
512
|
+
* // Traditional usage
|
|
513
|
+
* const handle = adapter.tailStreaming('/path/to/file');
|
|
514
|
+
* try {
|
|
515
|
+
* for await (const line of handle.lines) { console.log(line); }
|
|
516
|
+
* } finally {
|
|
517
|
+
* handle.stop();
|
|
518
|
+
* }
|
|
519
|
+
*
|
|
520
|
+
* // With await using (recommended)
|
|
521
|
+
* await using handle = adapter.tailStreaming('/path/to/file');
|
|
522
|
+
* for await (const line of handle.lines) { console.log(line); }
|
|
523
|
+
* // Automatically stopped when scope exits
|
|
524
|
+
* ```
|
|
490
525
|
*/
|
|
491
|
-
interface TailHandle {
|
|
526
|
+
interface TailHandle extends AsyncDisposable {
|
|
492
527
|
/** Async iterator for new lines */
|
|
493
528
|
readonly lines: AsyncIterable<string>;
|
|
494
529
|
/** Stop tailing */
|
|
@@ -433,8 +433,25 @@ type StreamHandler = {
|
|
|
433
433
|
* Handle to a spawned process
|
|
434
434
|
*
|
|
435
435
|
* Allows streaming output and waiting for completion.
|
|
436
|
+
* Implements AsyncDisposable for use with `await using`.
|
|
437
|
+
*
|
|
438
|
+
* @example
|
|
439
|
+
* ```typescript
|
|
440
|
+
* // Traditional usage
|
|
441
|
+
* const handle = adapter.spawnStreaming({ argv: ['git', 'fetch'] });
|
|
442
|
+
* try {
|
|
443
|
+
* for await (const line of handle.stdout) { console.log(line); }
|
|
444
|
+
* } finally {
|
|
445
|
+
* handle.kill();
|
|
446
|
+
* }
|
|
447
|
+
*
|
|
448
|
+
* // With await using (recommended)
|
|
449
|
+
* await using handle = adapter.spawnStreaming({ argv: ['git', 'fetch'] });
|
|
450
|
+
* for await (const line of handle.stdout) { console.log(line); }
|
|
451
|
+
* // Automatically disposed when scope exits
|
|
452
|
+
* ```
|
|
436
453
|
*/
|
|
437
|
-
interface SpawnHandle {
|
|
454
|
+
interface SpawnHandle extends AsyncDisposable {
|
|
438
455
|
/** Async iterator for stdout lines */
|
|
439
456
|
readonly stdout: AsyncIterable<string>;
|
|
440
457
|
/** Async iterator for stderr lines */
|
|
@@ -487,8 +504,26 @@ type TailOptions = {
|
|
|
487
504
|
};
|
|
488
505
|
/**
|
|
489
506
|
* Handle to a tail operation
|
|
507
|
+
*
|
|
508
|
+
* Implements AsyncDisposable for use with `await using`.
|
|
509
|
+
*
|
|
510
|
+
* @example
|
|
511
|
+
* ```typescript
|
|
512
|
+
* // Traditional usage
|
|
513
|
+
* const handle = adapter.tailStreaming('/path/to/file');
|
|
514
|
+
* try {
|
|
515
|
+
* for await (const line of handle.lines) { console.log(line); }
|
|
516
|
+
* } finally {
|
|
517
|
+
* handle.stop();
|
|
518
|
+
* }
|
|
519
|
+
*
|
|
520
|
+
* // With await using (recommended)
|
|
521
|
+
* await using handle = adapter.tailStreaming('/path/to/file');
|
|
522
|
+
* for await (const line of handle.lines) { console.log(line); }
|
|
523
|
+
* // Automatically stopped when scope exits
|
|
524
|
+
* ```
|
|
490
525
|
*/
|
|
491
|
-
interface TailHandle {
|
|
526
|
+
interface TailHandle extends AsyncDisposable {
|
|
492
527
|
/** Async iterator for new lines */
|
|
493
528
|
readonly lines: AsyncIterable<string>;
|
|
494
529
|
/** Stop tailing */
|
package/dist/index.cjs
CHANGED
|
@@ -444,7 +444,7 @@ function parseGitLog(stdout) {
|
|
|
444
444
|
if (fields.length < 11) {
|
|
445
445
|
continue;
|
|
446
446
|
}
|
|
447
|
-
const hash = fields[0];
|
|
447
|
+
const hash = fields[0]?.trim();
|
|
448
448
|
const abbrevHash = fields[1];
|
|
449
449
|
const parentsStr = fields[2];
|
|
450
450
|
const authorName = fields[3];
|
|
@@ -6040,6 +6040,13 @@ var NodeExecAdapter = class {
|
|
|
6040
6040
|
wait: () => waitPromise,
|
|
6041
6041
|
kill: (sig) => {
|
|
6042
6042
|
child.kill(sig ?? "SIGTERM");
|
|
6043
|
+
},
|
|
6044
|
+
[Symbol.asyncDispose]: async () => {
|
|
6045
|
+
if (child.exitCode === null) {
|
|
6046
|
+
child.kill("SIGTERM");
|
|
6047
|
+
}
|
|
6048
|
+
await waitPromise.catch(() => {
|
|
6049
|
+
});
|
|
6043
6050
|
}
|
|
6044
6051
|
};
|
|
6045
6052
|
}
|
|
@@ -6087,7 +6094,8 @@ function createTailPolling(options) {
|
|
|
6087
6094
|
state.resolveNext = null;
|
|
6088
6095
|
}
|
|
6089
6096
|
};
|
|
6090
|
-
startPollingLoop(adapter, state, signal, pollInterval, stop)
|
|
6097
|
+
const pollingPromise = startPollingLoop(adapter, state, signal, pollInterval, stop);
|
|
6098
|
+
pollingPromise.catch(() => {
|
|
6091
6099
|
});
|
|
6092
6100
|
const lines = {
|
|
6093
6101
|
[Symbol.asyncIterator]() {
|
|
@@ -6109,7 +6117,15 @@ function createTailPolling(options) {
|
|
|
6109
6117
|
};
|
|
6110
6118
|
}
|
|
6111
6119
|
};
|
|
6112
|
-
return {
|
|
6120
|
+
return {
|
|
6121
|
+
lines,
|
|
6122
|
+
stop,
|
|
6123
|
+
[Symbol.asyncDispose]: async () => {
|
|
6124
|
+
stop();
|
|
6125
|
+
await pollingPromise.catch(() => {
|
|
6126
|
+
});
|
|
6127
|
+
}
|
|
6128
|
+
};
|
|
6113
6129
|
}
|
|
6114
6130
|
async function startPollingLoop(adapter, state, signal, pollInterval, stop) {
|
|
6115
6131
|
let position = 0;
|
|
@@ -6133,6 +6149,9 @@ async function startPollingLoop(adapter, state, signal, pollInterval, stop) {
|
|
|
6133
6149
|
}
|
|
6134
6150
|
}
|
|
6135
6151
|
}
|
|
6152
|
+
if (state.stopped || signal?.aborted) {
|
|
6153
|
+
break;
|
|
6154
|
+
}
|
|
6136
6155
|
await adapter.sleep(pollInterval);
|
|
6137
6156
|
}
|
|
6138
6157
|
stop();
|
|
@@ -6221,16 +6240,26 @@ var NodeFsAdapter = class {
|
|
|
6221
6240
|
sleep: (ms) => new Promise((resolve) => setTimeout(resolve, ms))
|
|
6222
6241
|
};
|
|
6223
6242
|
const polling = createTailPolling({ adapter, signal, pollInterval });
|
|
6224
|
-
const
|
|
6225
|
-
const enhancedStop = () => {
|
|
6226
|
-
originalStop();
|
|
6243
|
+
const closeFileHandle = async () => {
|
|
6227
6244
|
if (state.file) {
|
|
6228
|
-
state.file.close().catch(() => {
|
|
6245
|
+
await state.file.close().catch(() => {
|
|
6229
6246
|
});
|
|
6230
6247
|
state.file = null;
|
|
6231
6248
|
}
|
|
6232
6249
|
};
|
|
6233
|
-
|
|
6250
|
+
const originalStop = polling.stop;
|
|
6251
|
+
const enhancedStop = () => {
|
|
6252
|
+
originalStop();
|
|
6253
|
+
void closeFileHandle();
|
|
6254
|
+
};
|
|
6255
|
+
return {
|
|
6256
|
+
lines: polling.lines,
|
|
6257
|
+
stop: enhancedStop,
|
|
6258
|
+
[Symbol.asyncDispose]: async () => {
|
|
6259
|
+
await polling[Symbol.asyncDispose]();
|
|
6260
|
+
await closeFileHandle();
|
|
6261
|
+
}
|
|
6262
|
+
};
|
|
6234
6263
|
}
|
|
6235
6264
|
};
|
|
6236
6265
|
|