MCPcopy Create free account
hub / github.com/Script-Hub-Org/Script-Hub / generateHTML

Function generateHTML

preview.js:10–23  ·  view source on GitHub ↗
(config, info = '')

Source from the content-addressed store, hash-verified

8const EXPORT_HTML = process.env.EXPORT_HTML
9
10const generateHTML = (config, info = '') => {
11 const content = fs.readFileSync(config[1], { encoding: 'utf8' })
12 let html =
13 content.match(/<!DOCTYPE html>([\s\S]*?<body style="margin-bottom: 80px;"><script>)/i)[1] +
14 '</script><script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>' +
15 content.match(/(<div id="app">[\s\S]*?)<\/html>/i)[1].replace("${$.getEnv() || ''}", 'Node.js' + info)
16 const rewriteParser = fs.readFileSync(config[2], { encoding: 'utf8' })
17 const ruleParser = fs.readFileSync(config[3], { encoding: 'utf8' })
18 const scriptConverter = fs.readFileSync(config[4], { encoding: 'utf8' })
19 return html.replace(
20 '"__SCRIPT__"',
21 JSON.stringify({ scriptConverter, rewriteParser, ruleParser, scriptMap: config[5] })
22 )
23}
24
25if (EXPORT_HTML) {
26 // fs.rmdirSync(path.join(__dirname, './dist'), { recursive: true })

Callers 1

preview.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected