Skip to content

Commit dca5f57

Browse files
authored
fix(index.js): remove var
1 parent 3bc4e9f commit dca5f57

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

webhook/index.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,8 @@ var YAML = require('yaml');
33
var createHandler = require('github-webhook-handler');
44
var handler = createHandler({ path: '/MY_SECRET_PATH', secret: 'MY_SECRET_KEY' });
55
const elasticsearch = require('elasticsearch');
6-
const esHost = 'localhost:9200';
7-
const articlePath = '/home/ubuntu/OI-wiki';
86
var client = new elasticsearch.Client({
9-
host: esHost,
7+
host: 'localhost:9200',
108
});
119

1210

@@ -48,7 +46,7 @@ function traversalArticle(data, callback) {
4846
function getContent(filename, data) {
4947
let file;
5048
try {
51-
file = String(fs.readFileSync(`${articlePath}/docs/` + filename));
49+
file = String(fs.readFileSync(`/home/ubuntu/OI-wiki/docs/` + filename));
5250
} catch (e) {
5351
console.error(`Error reading file ${filename}:`, e);
5452
return ['', '', ''];
@@ -85,7 +83,7 @@ function getContent(filename, data) {
8583
* @param removed - Array of removed files
8684
*/
8785
function updateContent(modified, removed) {
88-
const file = String(fs.readFileSync(`${articlePath}/mkdocs.yml`));
86+
const file = String(fs.readFileSync(`/home/ubuntu/OI-wiki/mkdocs.yml`));
8987
const data = YAML.parse(file.replaceAll('!!python/name:', ''));
9088
let ops = [];
9189
modified.forEach((filename) => {
@@ -160,9 +158,9 @@ handler.on('push', (event) => {
160158
});
161159

162160
function init() {
163-
exec(`curl -X DELETE "http://${esHost}/oiwiki"`);
161+
exec(`curl -X DELETE "http://localhost:9200/oiwiki"`);
164162
let modified = [];
165-
const file = String(fs.readFileSync(`${articlePath}/mkdocs.yml`));
163+
const file = String(fs.readFileSync(`/home/ubuntu/OI-wiki/mkdocs.yml`));
166164
const data = YAML.parse(file.replaceAll('!!python/name:', ''));
167165
traversalArticle(data['nav'], (key, value) => modified.push(value));
168166
updateContent(modified, []);

0 commit comments

Comments
 (0)