make data folder automaically

This commit is contained in:
2026-08-13 21:39:10 +09:00
parent d87bd4111e
commit 973f3e36da
2 changed files with 6 additions and 981 deletions
+1 -979
View File
File diff suppressed because one or more lines are too long
+5 -2
View File
@@ -10,14 +10,17 @@ const CSV_FILE = path.join(BASE, 'data', 'responses.csv');
// Compile SCSS on startup // Compile SCSS on startup
try { try {
const cssDir = path.join(BASE, 'public', 'css');
fs.mkdirSync(cssDir, { recursive: true });
const result = sass.compile(path.join(BASE, 'src', 'styles', 'main.scss'), { style: 'compressed' }); const result = sass.compile(path.join(BASE, 'src', 'styles', 'main.scss'), { style: 'compressed' });
fs.writeFileSync(path.join(BASE, 'public', 'css', 'main.css'), result.css); fs.writeFileSync(path.join(cssDir, 'main.css'), result.css);
console.log('SCSS compiled successfully'); console.log('SCSS compiled successfully');
} catch (err) { } catch (err) {
console.error('SCSS compile error:', err.message); console.error('SCSS compile error:', err.message);
} }
// Ensure data files exist // Ensure data directory & files exist (data/ is gitignored, so a fresh clone has neither)
fs.mkdirSync(path.dirname(DATA_FILE), { recursive: true });
if (!fs.existsSync(DATA_FILE)) fs.writeFileSync(DATA_FILE, JSON.stringify([], null, 2)); if (!fs.existsSync(DATA_FILE)) fs.writeFileSync(DATA_FILE, JSON.stringify([], null, 2));
if (!fs.existsSync(CSV_FILE)) fs.writeFileSync(CSV_FILE, buildCSVHeader() + '\n'); if (!fs.existsSync(CSV_FILE)) fs.writeFileSync(CSV_FILE, buildCSVHeader() + '\n');