forked from JaylyDev/ScriptAPI
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.ts
More file actions
39 lines (31 loc) · 1.14 KB
/
index.ts
File metadata and controls
39 lines (31 loc) · 1.14 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
37
38
39
import * as headerChecks from "./headerChecks";
import * as packageCheck from "./packageCheck";
import * as testScriptChecks from "./testScriptChecks";
import * as readme from "./packageReadme";
function log (...args: string[]) {
console.log('');
console.log(...args, '\n');
};
interface Task {
message: string;
execute: () => 0 | 1;
};
function runTasks (tasks: Task[]): number {
const taskStatus: number[] = [];
for (const task of tasks) {
log(task.message + '...');
const statusCode = task.execute();
taskStatus.push(statusCode);
};
console.log(taskStatus.map((status, index) => `Task: ${tasks[index].message}, Status: ${status}`));
if (taskStatus.length <= 0) return 1;
else if (taskStatus.filter(status => status !== 0).length > 0) return 1;
else return 0;
};
const exitCode = runTasks([
{ message: "Checking script file headers", execute: headerChecks.execute },
{ message: "Checking script names", execute: packageCheck.execute },
{ message: "Looking for test files in packages", execute: testScriptChecks.execute },
{ message: "Adding README for packages", execute: readme.execute },
]);
process.exit(exitCode);