Passed
Push — master ( 622eb3...88f58b )
by Vinicius
01:47
created

src/index.ts   A

Complexity

Total Complexity 3
Complexity/F 1.5

Size

Lines of Code 29
Function Count 2

Duplication

Duplicated Lines 0
Ratio 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 24
dl 0
loc 29
ccs 11
cts 11
cp 1
rs 10
c 0
b 0
f 0
wmc 3
mnd 1
bc 1
fnc 2
bpm 0.5
cpm 1.5
noi 0

1 Function

Rating   Name   Duplication   Size   Complexity  
A index.ts ➔ pikaResolver 0 19 3
1 1
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
2
import { Plugin } from 'rollup'
3 1
import { getVersion } from './version'
4
5 1
const PIKA_CDN_HOST = 'https://cdn.pika.dev'
6
7
function pikaResolver ({ modules, cdnHost = PIKA_CDN_HOST }: { modules: string[], cdnHost: string }) {
8 1
  const cache = new Map<string, string>()
9
10 1
  return {
11
    name: 'pika-resolver',
12
    async resolveId (id: string) {
13 2
      if (!modules.includes(id)) {
14 1
        return id
15
      }
16
17 1
      const version = await getVersion(this, cache, id)
18
19 1
      return {
20
        id: `${cdnHost}/${version}`,
21
        external: true
22
      }
23
    }
24
  } as Plugin
25
}
26
27 1
export { pikaResolver }
28
export default pikaResolver
29