feat(bisaya-course): enhance script execution with direct run detection
All checks were successful
Deploy to production / deploy (push) Successful in 4m25s
All checks were successful
Deploy to production / deploy (push) Successful in 4m25s
- Added functionality to detect if the script is run directly, allowing for conditional execution of the main function. - Imported `pathToFileURL` from the 'url' module to facilitate the direct run check, improving script usability and flexibility.
This commit is contained in:
@@ -10,6 +10,7 @@ import { sequelize } from '../utils/sequelize.js';
|
|||||||
import VocabCourseLesson from '../models/community/vocab_course_lesson.js';
|
import VocabCourseLesson from '../models/community/vocab_course_lesson.js';
|
||||||
import { getBisayaLessonPedagogy } from './bisaya-course-phase2-pedagogy.js';
|
import { getBisayaLessonPedagogy } from './bisaya-course-phase2-pedagogy.js';
|
||||||
import { BISAYA_DIDACTICS_FRAGMENTS } from './bisaya-course-phase1.js';
|
import { BISAYA_DIDACTICS_FRAGMENTS } from './bisaya-course-phase1.js';
|
||||||
|
import { pathToFileURL } from 'url';
|
||||||
import {
|
import {
|
||||||
BISAYA_DIDACTICS_24_43,
|
BISAYA_DIDACTICS_24_43,
|
||||||
BISAYA_LESSONS_24_43_BY_NUMBER,
|
BISAYA_LESSONS_24_43_BY_NUMBER,
|
||||||
@@ -569,4 +570,10 @@ async function main() {
|
|||||||
process.exit(process.exitCode ?? 0);
|
process.exit(process.exitCode ?? 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
main();
|
const isDirectRun = process.argv[1]
|
||||||
|
? import.meta.url === pathToFileURL(process.argv[1]).href
|
||||||
|
: false;
|
||||||
|
|
||||||
|
if (isDirectRun) {
|
||||||
|
main();
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user