-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.ts
28 lines (22 loc) · 815 Bytes
/
index.ts
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
import * as fs from 'fs'
import { parseAndRun } from './parser'
const reset = '\x1b[0m'
const green = '\x1b[32m'
const underlined = '\x1b[4m'
const magenta = '\x1b[35m'
const paths: string[] = process.argv
paths.splice(0, 2)
if (paths.length === 0) {
console.log(`${magenta}Correct usage: ${green}node out/index ...<path-to-file-from-project-folder> ${magenta}${underlined}or${reset}${green} npm test${reset}`)
}
paths.forEach(function runPaths (val: string) {
let program: string
try {
program = `${fs.readFileSync(`${val}`)}`
} catch {
return console.log(`${magenta}Correct usage: ${green}node out/index ...<path-to-file-from-project-folder> ${magenta}${underlined}or${reset}${green} npm test${reset}`)
}
console.log(`${green}${val}: ${reset}`)
parseAndRun(program)
console.log()
})