-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcreate.js
More file actions
36 lines (28 loc) · 1.02 KB
/
create.js
File metadata and controls
36 lines (28 loc) · 1.02 KB
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
const fs = require('fs');
const path = require('path');
// Config
const distDir = path.resolve('dist');
const templatePath = path.resolve('template.html');
const outputHtml = path.join(distDir, 'index.html');
const minifiedScript = 'yo.min.js';
// Ensure dist folder exists
if (!fs.existsSync(distDir)) {
fs.mkdirSync(distDir, { recursive: true });
}
// Check if template exists
if (!fs.existsSync(templatePath)) {
console.error(`❌ Template not found: ${templatePath}`);
console.error('Please create template.html with the HTML structure.');
process.exit(1);
}
// Read template
let html = fs.readFileSync(templatePath, 'utf-8');
// Simple placeholder replacement
// You can add more placeholders later (title, version, etc.)
html = html.replace('YOUR_MINIFIED_SCRIPT', minifiedScript);
if (!html.includes(minifiedScript)) {
console.warn('⚠️ Warning: "YOUR_MINIFIED_SCRIPT" placeholder not found in template.');
}
// Write final file
fs.writeFileSync(outputHtml, html);
console.log(`✅ Test page generated: ${outputHtml}`);