-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.mjs
49 lines (40 loc) · 1.35 KB
/
app.mjs
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
37
38
39
40
41
42
43
44
45
46
47
48
49
/**
* @name CourseLinkFixer
* @file app.mjs
* @description The entry point for the CourseLink fixer script.
* @author gorayas
* @version 0.0.2
*/
import internal from './package.json' assert { type: "json" };
import { log } from './src/lib.mjs';
import {
removeUnneededFiles,
renameFiles,
getNames
} from './src/functions.mjs';
/**
* This function acts as a wrapper for the script. This is only done to make
* the script compatible with the packaging and minifying tools used to make the
* script executable outside of the node.js environment.
*
* These packagers don't yet support esmodules, and have no support for top-level
* await.
*/
async function run() {
log(`- CourseLink Fixer x V ${internal.version} - `, 'big');
log(`Source & Instructions Available at: https://github.com/surajgoraya`, 'note');
log('Starting...', 'info');
log('Importing sanitized names file...', 'debug');
const sorted_names = await getNames();
if (sorted_names.length) {
log('Read names, keeping only needed files...', 'success');
await removeUnneededFiles(sorted_names);
log('Files not needed for this week moved, renaming...', 'success');
await renameFiles(sorted_names);
} else {
log('Names File Empty! - Exiting.', 'error');
process.exit(1);
}
log('Done!', 'success');
}
run();