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

pkgxdev / libpkgx / 6578274712

19 Oct 2023 05:40PM UTC coverage: 81.055%. First build
6578274712

push

github

web-flow
Merge pull request #48 from pkgxdev/v1

v1 wip

480 of 668 branches covered (0.0%)

Branch coverage included in aggregate %.

170 of 191 new or added lines in 14 files covered. (89.01%)

2164 of 2594 relevant lines covered (83.42%)

1000.88 hits per line

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

90.0
/src/hooks/useTestConfig.ts
1
import useConfig, { ConfigDefault } from "./useConfig.ts"
45✔
2
import Path from "../utils/Path.ts"
45✔
3

4
export function useBaseTestConfig(env?: Record<string, string>) {
45✔
5
  env ??= {}
127✔
6

7
  /// always prefer a new prefix
127✔
8
  env.HOME ??= Path.mktemp().string
127✔
9
  env.PKGX_DIR ??= Path.mktemp().string
127✔
10
  env.XDG_DATA_HOME ??= Path.mktemp().string
127✔
11
  env.XDG_CACHE_HOME ??= Path.mktemp().string
127✔
12

13
  const config = ConfigDefault(env)
127✔
14
  if ('UserAgent' in env) {
127✔
15
    config.UserAgent = env['UserAgent']
130✔
16
  }
130✔
17

18
  return useConfig(config)
127✔
19
}
127✔
20

21
import usePantry from "./usePantry.ts"
45✔
22

23
export function useTestConfig(env?: Record<string, string>) {
45✔
24
  const conf = useBaseTestConfig(env)
127✔
25
  copyDirectory(srcroot.join("fixtures/projects").string, usePantry().prefix.mkdir('p').string)
127✔
26
  return conf
127✔
27
}
127✔
28

29
export const srcroot = (() => {
45✔
30
  // because when running via dnt the path of this file is different
90✔
NEW
31
  if (Path.cwd().parent().parent().join("fixtures").isDirectory()) {
×
NEW
32
    return Path.cwd().parent().parent()
×
NEW
33
  } else {
×
34
    let path = new URL(import.meta.url).pathname
90✔
35
    if (Deno.build.os == 'windows') {
30!
36
      path = path.slice(1) // /D:/foo/bar -> D:/foo/bar
30✔
37
    }
30✔
38
    return new Path(path).parent().parent().parent()
90✔
39
  }
90✔
40
})()
45✔
41

42
import { walkSync } from 'deno/fs/mod.ts'
45✔
43

44
// deno/dnt has a broken shim for this function
3✔
45
function copyDirectory(src: string, dest: string) {
127✔
46
  for (const entry of walkSync(src)) {
127✔
47
    const destPath = entry.path.replace(src, dest);
947✔
48

49
    if (entry.isDirectory) {
947✔
50
      Deno.mkdirSync(destPath, { recursive: true });
4,071✔
51
    } else {
1,357✔
52
      Deno.copyFileSync(entry.path, destPath);
1,357✔
53
    }
1,357✔
54
  }
947✔
55
}
127✔
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