Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto create PR when data updated #7

Merged
merged 7 commits into from
Feb 20, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions .github/workflows/update.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Update

on:
workflow_dispatch:
schedule:
# “At 00:00 on Sunday.” https://crontab.guru/#0_0_*_*_0
- cron: "0 0 * * 0"

jobs:
update:
if: github.event_name != 'schedule' || github.repository == 'sindresorhus/get-east-asian-width'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- run: npm install
- run: npm run build
- uses: peter-evans/create-pull-request@v6
with:
commit-message: Update
branch: automated-update
branch-suffix: timestamp
title: Update
8 changes: 4 additions & 4 deletions scripts/build.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import fs from 'node:fs';
import fs from 'node:fs/promises';
import assert from 'node:assert/strict';
import simplifyRanges from 'simplify-ranges';
import {outdent} from 'outdent';
Expand Down Expand Up @@ -104,8 +104,8 @@ const text = await response.text();
const parsed = parse(text);
const functions = generateFunctions(parsed);

fs.writeFileSync(
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Synchronous writing is significantly faster than async when you don't need concurrency, so the only way this change is beneficial is if you do the two file writings with Promise.all.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reverted.

'lookup.js',
await fs.writeFile(
new URL('../lookup.js', import.meta.url),
outdent`
// Generated code.

Expand All @@ -115,4 +115,4 @@ fs.writeFileSync(
` + '\n',
);

fs.writeFileSync('scripts/EastAsianWidth.txt', text);
await fs.writeFile(new URL('EastAsianWidth.txt', import.meta.url), text);