-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.js
More file actions
29 lines (24 loc) · 761 Bytes
/
Copy pathrun.js
File metadata and controls
29 lines (24 loc) · 761 Bytes
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
import fs from 'fs';
import path from 'path';
import { fileURLToPath } from 'url';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const day = process.argv[2];
async function runDay(day) {
const dayPath = path.resolve(__dirname, `src/day${day}/index.js`);
if (fs.existsSync(dayPath)) {
const module = await import(dayPath); // Esegui il codice del giorno specifico
if (typeof module.main === 'function') {
module.main();
} else {
console.log(`Day ${day} loaded successfully (no main function found)`);
}
} else {
console.error(`Day ${day} script not found.`);
}
}
if (day) {
runDay(day);
} else {
console.log('Please provide a day number (e.g. npm start day1)');
}