Skip to content
This repository was archived by the owner on Oct 2, 2019. It is now read-only.

Commit fc2ca58

Browse files
committed
🚨 Replace require calls to generated files with fs.readFileSync+JSON.parse
1 parent baae6d3 commit fc2ca58

File tree

4 files changed

+12
-6
lines changed

4 files changed

+12
-6
lines changed

scripts/generate-ci-comment.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ if (!fs.existsSync('public/calendar.json')) {
2828
}
2929

3030
if (fs.existsSync('tmp/readme-parse-diagnostic.json')) {
31-
const diagnostics = require('../tmp/readme-parse-diagnostic.json')
31+
const diagnostics = JSON.parse(
32+
fs.readFileSync('tmp/readme-parse-diagnostic.json', 'utf8')
33+
)
3234
if (diagnostics.errors && diagnostics.errors.length) {
3335
console.log(':x: **ข้อผิดพลาดในการประมวลผลไฟล์ (Processing errors):**')
3436
console.log()

scripts/generate-event-html-files.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
const fs = require('fs')
1414

1515
const html = fs.readFileSync('public/index.html', 'utf8')
16-
const data = require('../public/calendar')
16+
const data = JSON.parse(fs.readFileSync('public/calendar.json', 'utf8'))
1717
const mkdirp = require('mkdirp')
1818
const path = require('path')
1919
const escapeHtml = require('escape-html')

scripts/generate-ics.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// Generates ICS file from `public/calendar.json`
22

3-
const data = require('../public/calendar')
3+
const fs = require('fs')
4+
5+
const data = JSON.parse(fs.readFileSync('public/calendar.json', 'utf8'))
46
const icalendar = require('icalendar')
57

68
const ICalendar = icalendar.iCalendar
@@ -76,6 +78,6 @@ function generateICS() {
7678

7779
const ics = generateICS()
7880
const path = `public/calendar.ics`
79-
require('fs').writeFileSync(path, ics)
81+
fs.writeFileSync(path, ics)
8082

8183
console.log('* Generated', path)

scripts/generate-svg.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// Generates SVG file from `public/calendar.json`
22

3-
const data = require('../public/calendar')
3+
const fs = require('fs')
4+
5+
const data = JSON.parse(fs.readFileSync('public/calendar.json', 'utf8'))
46

57
const totalWidth = 200
68
const totalHeight = 185
@@ -105,7 +107,7 @@ for (let year = 2018; year <= 2018; year += 1) {
105107
const path = `public/generated/calendar-images/${year}-${String(
106108
month + 1
107109
).padStart(2, '0')}.svg`
108-
require('fs').writeFileSync(path, svg)
110+
fs.writeFileSync(path, svg)
109111
console.log('* Generated', path)
110112
}
111113
}

0 commit comments

Comments
 (0)