-
Notifications
You must be signed in to change notification settings - Fork 0
/
dev.js
38 lines (30 loc) · 1.28 KB
/
dev.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
import dotenv from 'dotenv'
import { existsSync } from 'fs'
import { readFile } from 'fs/promises'
import { join } from 'path'
export function handleLocalDev (__dirname) {
if (!process.env.GITHUB_ACTIONS) {
console.log('Running locally')
// Check if the .env file exists
if (!existsSync(join(__dirname, '.env'))) {
if (existsSync(join(__dirname, '.env.local'))) {
console.log('No .env file found, using .env.local instead.')
dotenv.config({ path: join(__dirname, '.env.local') })
} else {
console.log('No .env or .env.local file found, I hope you know what you\'re doing.')
}
} else {
dotenv.config()
}
return true
}
return false
}
export async function getExampleTimetable (__dirname) {
console.log('Getting example timetable...')
const screenshotFilePath = join(__dirname, '.github', 'example', '2022-04-26T23-56-11-760Z.png')
const pdfFilePath = join(__dirname, '.github', 'example', '2022-04-26T23-56-11-760Z.pdf')
const jsonFilePath = join(__dirname, '.github', 'example', '2022-04-26T23-56-11-760Z.json')
const timetableJson = JSON.parse(await readFile(jsonFilePath, 'utf8'))
return { weekText: 'Week 35 (25-APR-22)', screenshotFilePath, pdfFilePath, timetableJson }
}