forked from mayasingh2711/calender
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcreateConfigVariable.js
45 lines (36 loc) · 1.07 KB
/
createConfigVariable.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
/* eslint-disable no-sync */
'use strict';
var fs = require('fs');
var path = require('path');
var config = require(path.resolve(process.cwd(), 'tuidoc.config.json'));
var examples = config.examples || {};
var filePath = examples.filePath;
var globalErrorLogVariable = examples.globalErrorLogVariable;
/**
* Get Examples Url
*/
function getTestUrls() {
var urlPrefix = 'http://nhn.github.io/tui.calendar/latest';
var testUrls;
if (!filePath) {
throw Error('not exist examples path at tuidoc.config.json');
}
testUrls = fs.readdirSync(filePath).reduce(function(urls, fileName) {
if (/html$/.test(fileName)) {
urls.push(urlPrefix + '/' + filePath + '/' + fileName);
}
return urls;
}, []);
fs.writeFileSync('url.txt', testUrls.join(', '));
}
/**
* Get Global Variable
*/
function getGlobalVariable() {
if (!globalErrorLogVariable) {
throw Error('not exist examples path at tuidoc.config.json');
}
fs.writeFileSync('errorVariable.txt', globalErrorLogVariable);
}
getTestUrls();
getGlobalVariable();