-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.js
executable file
·49 lines (41 loc) · 1.35 KB
/
index.js
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
const Utils = require("./build/core/utils").default
const convertStories = (config = {}) => {
if(config.outputType) {
switch (config.outputType.toLowerCase()) {
case "puppeteer": {
const Core = require("./build/templates/puppeteer/core").default
const convertor = new Core()
convertor.setConfig({
out: config.out || './spec',
headers: config.headers || {},
path: config.pathToYaml
})
if (config.clean !== false) {
Utils.cleanOutputDir(config.out || './spec')
}
if (config.together) {
convertor.loadFilesConvertThemAndSaveTogether()
break
}
convertor.loadFilesConvertThemAndSaveSeparatelly()
break
}
default: throw new Error("Invalid output type, use only ones specified in the docs.")
}
} else {
const Core = require("./build/templates/puppeteer/core").default
const convertor = new Core()
convertor.setConfig({
out: config.out || './spec',
headers: config.headers || {},
path: config.pathToYaml
})
if (config.clean !== false) {
Utils.cleanOutputDir(config.out || './spec')
}
config.together
? convertor.loadFilesConvertThemAndSaveTogether()
: convertor.loadFilesConvertThemAndSaveSeparatelly()
}
}
module.exports = convertStories