-
-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathbootstrap.ts
More file actions
50 lines (45 loc) · 1.43 KB
/
bootstrap.ts
File metadata and controls
50 lines (45 loc) · 1.43 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
40
41
42
43
44
45
46
47
48
49
50
import {
DirectoryInput,
Input,
Logger,
registerExceptionHandler,
setProcessLogger,
DirectoryWithConfigInput,
} from '@exercism/static-analysis'
import { ExerciseImpl } from '~src/ExerciseImpl'
import { ExecutionOptions, Exercise } from '~src/interface'
import { ExecutionOptionsImpl } from './execution_options'
export interface BootstrapResult {
exercise: Exercise
input: Input
options: ExecutionOptions
logger: Logger
}
/**
* The bootstrap call uses the arguments passed to the process to figure out
* which exercise to target, where the input lives (directory input) and what
* execution options to set.
*
* <entry> -dc two-fer ~/test/
*
* For example, if arguments are passed directly, the above will run the two-fer
* exercise analyzer with the ~/test/ input directory and turning on debug and
* console logging.
*/
export class Bootstrap {
/**
* Builds execution options, exercise and input based on the process arguments
*
*/
public static call(): BootstrapResult {
registerExceptionHandler()
const options = ExecutionOptionsImpl.create()
const logger = new Logger(options)
const exercise = new ExerciseImpl(options.exercise)
const input = DirectoryWithConfigInput.test(options.inputDir)
? new DirectoryWithConfigInput(options.inputDir)
: new DirectoryInput(options.inputDir, exercise.slug)
setProcessLogger(logger)
return { exercise, input, options, logger }
}
}