This repository has been archived by the owner on May 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path__info.js
64 lines (49 loc) · 1.8 KB
/
__info.js
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import { getViteConfigFilePath } from "../../adder-tools.js";
export const name = "CoffeeScript";
export const emoji = "☕️";
export const usageMarkdown = ['You can write CoffeeScript syntax in the `script lang="coffee"` blocks in Svelte files.', "You can write CoffeeScript syntax in `.coffee` files and import them elsewhere."];
/** @typedef {{}} Options */
/** @type {import("../..").Gatekeep} */
export const gatekeep = async () => {
return { able: true };
};
/** @type {import("../..").AdderOptions<Options>} */
export const options = {};
/** @type {import("../..").Heuristic[]} */
export const heuristics = [
{
description: "`coffeescript` is installed",
async detector({ folderInfo }) {
return "coffeescript" in folderInfo.allDependencies;
},
},
{
description: "`vitePreprocess` is set up for CoffeeScript in `svelte.config.js`",
async detector({ readFile }) {
/** @param {string} text */
const sveltePreprocessIsProbablySetup = (text) => {
if (!text.includes("vitePreprocess")) return false;
return true;
};
const js = await readFile({ path: "/svelte.config.js" });
const cjs = await readFile({ path: "/svelte.config.cjs" });
if (js.exists) return sveltePreprocessIsProbablySetup(js.text);
else if (cjs.exists) return sveltePreprocessIsProbablySetup(cjs.text);
return false;
},
},
{
description: "The Vite CoffeeScript plugin is set up",
async detector({ readFile, folderInfo }) {
/** @param {string} text */
const vitePluginIsProbablySetup = (text) => {
if (!text.includes("vite-plugin-coffee")) return false;
if (!text.includes("coffee(")) return false;
return true;
};
const vite = await readFile({ path: `/${getViteConfigFilePath(folderInfo)}` });
if (vitePluginIsProbablySetup(vite.text)) return true;
return false;
},
},
];