forked from webpro-nl/knip
-
Notifications
You must be signed in to change notification settings - Fork 0
/
helpers.ts
33 lines (30 loc) · 988 Bytes
/
helpers.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
export const resolvePluginName = (pluginName: string) => {
if (!/babel/.test(pluginName)) return `babel-plugin-${pluginName}`;
if (pluginName.startsWith('@babel/')) {
if (pluginName.startsWith('@babel/plugin')) return pluginName;
const [, name] = pluginName.split('/');
return `@babel/plugin-${name}`;
}
return pluginName;
};
export const resolvePresetName = (pluginName: string) => {
if (!/babel/.test(pluginName)) return `babel-preset-${pluginName}`;
if (pluginName.startsWith('@babel/')) {
if (pluginName.startsWith('@babel/preset')) return pluginName;
const [, name] = pluginName.split('/');
return `@babel/preset-${name}`;
}
return pluginName;
};
const cacheFn = () => void 0;
cacheFn.forever = () => cacheFn;
cacheFn.never = () => cacheFn;
cacheFn.using = () => cacheFn;
cacheFn.invalidate = () => cacheFn;
export const api = {
assertVersion: () => true,
cache: cacheFn,
caller: () => true,
env: () => true,
version: '0.0.0',
};