-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.ts
45 lines (35 loc) · 884 Bytes
/
config.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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import fs from "fs"
import Shell from "shelljs"
const configFileName = "./gifitconfig.json"
interface ConfigFile{
path:string;
filePrefix:string;
outputFolder:string;
}
/**
*
*
*
* @returns path, filePrefix, outputFolder
*
*
*/
export default function Config(): ConfigFile{
const configJson = fs.existsSync(configFileName)?
JSON.parse(Shell.cat(configFileName)) :
null
if(!configJson?.outputFolder){
if(!fs.existsSync("./GifitOutput")){
Shell.mkdir("./GifitOutput")
}
}else{
if(!fs.existsSync(`./${configJson.outputFolder}`)){
Shell.mkdir(`./${configJson.outputFolder}`)
}
}
return({
path: configJson?.path ?? "http://localhost:3000/",
filePrefix: configJson?.filePrefix ?? "picture",
outputFolder: configJson?.outputFolder ?? "./GifitOutput"
})
}