Skip to content

Commit

Permalink
fix: update workflow scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
toFrankie committed Jan 18, 2025
1 parent f915b6a commit 6b641c2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
7 changes: 5 additions & 2 deletions scripts/update-recent-articles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,11 @@ async function updateRecentArticles() {
const content = lines.join('\n')
const filePath = path.join('docs', 'recent-articles.md')

const dirPath = path.dirname(filePath)
await fs.mkdir(dirPath, { recursive: true })
const recentArticlesDir = path.dirname(filePath)
const dirExists = await fs.stat(recentArticlesDir).catch(() => false)
if (!dirExists) {
await fs.mkdir(recentArticlesDir, { recursive: true })
}

await fs.writeFile(filePath, content, 'utf8')
}
Expand Down
5 changes: 4 additions & 1 deletion scripts/update-traffic-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,10 @@ async function updateAllTrafficJson(trafficDir: string, allJsonPath: string) {
const trafficData = await getTrafficViews()

const trafficDir = path.resolve('docs/traffic')
await fs.mkdir(trafficDir, { recursive: true })
const trafficDirExists = await fs.stat(trafficDir).catch(() => false)
if (!trafficDirExists) {
await fs.mkdir(trafficDir, { recursive: true })
}

const trafficDataYearly = Object.groupBy(trafficData.views, item =>
dayjs(item.timestamp).format('YYYY'),
Expand Down

0 comments on commit 6b641c2

Please sign in to comment.