• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

nikelborm / fetch-github-folder / 12944300402

24 Jan 2025 06:11AM UTC coverage: 82.596% (-0.2%) from 82.833%
12944300402

push

github

nikelborm
quick save: Fri Jan 24 09:11:36 MSK 2025

73 of 83 branches covered (87.95%)

Branch coverage included in aggregate %.

5 of 8 new or added lines in 2 files covered. (62.5%)

506 of 618 relevant lines covered (81.88%)

4.17 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

97.22
/src/unpackRepoFolderTarGzStreamToFs.ts
1
import { Effect, gen, tryPromise } from 'effect/Effect';
1✔
2
import { Readable } from 'node:stream';
3
import { pipeline } from 'node:stream/promises';
4
import { createGunzip } from 'node:zlib';
5
import { extract } from 'tar-fs';
6
import { OutputConfigTag } from './configContext.js';
7
import {
8
  TaggedErrorClassWithUnknownCauseAndNoContext,
9
  TaggedErrorVerifyingCause,
10
} from './TaggedErrorVerifyingCause.js';
11

12
export const unpackRepoFolderTarGzStreamToFs = <E, R>(
1✔
13
  self: Effect<Readable, E, R>,
1✔
14
) =>
15
  gen(function* () {
1✔
16
    const tarGzStream = yield* self;
1✔
17

18
    const {
1✔
19
      localPathAtWhichEntityFromRepoWillBeAvailable:
1✔
20
        pathToLocalDirWhichWillHaveContentsOfRepoDir,
1✔
21
    } = yield* OutputConfigTag;
1✔
22

23
    yield* tryPromise({
1✔
24
      try: signal =>
1✔
25
        pipeline(
1✔
26
          tarGzStream,
1✔
27
          createGunzip(),
1✔
28
          extract(pathToLocalDirWhichWillHaveContentsOfRepoDir, {
1✔
29
            map: header => {
1✔
30
              // GitHub creates archive with nested dir inside which has all
31
              // the files we need, so we remove this dir's name from the
32
              // beginning
33
              header.name = header.name.replace(/^[^/]*\/(.*)/, '$1');
133✔
34
              return header;
133✔
35
            },
133✔
36
          }),
1✔
37
          { signal },
1✔
38
        ),
1✔
39
      catch: cause =>
1✔
NEW
40
        new FailedToUnpackRepoFolderTarGzStreamToFsError({ cause }),
×
41
    });
1✔
42
  });
1✔
43

44
// Extracting to a separate type is required by JSR, so that consumers of the
45
// library will have much faster type inference
46
export type FailedToUnpackRepoFolderTarGzStreamToFsErrorClass =
47
  TaggedErrorClassWithUnknownCauseAndNoContext<'FailedToUnpackRepoFolderTarGzStreamToFsError'>;
48

49
export type FailedToUnpackRepoFolderTarGzStreamToFsError =
50
  InstanceType<FailedToUnpackRepoFolderTarGzStreamToFsErrorClass>;
51

52
const FailedToUnpackRepoFolderTarGzStreamToFsError: FailedToUnpackRepoFolderTarGzStreamToFsErrorClass =
1✔
53
  TaggedErrorVerifyingCause<{
1✔
54
    cause: unknown;
55
  }>()(
1✔
56
    'FailedToUnpackRepoFolderTarGzStreamToFsError',
1✔
57
    'Error: Failed to unpack to fs received from GitHub .tar.gz stream of repo folder contents',
1✔
58
  );
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc