Skip to content
Open
Changes from all 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
14 changes: 14 additions & 0 deletions .github/workflows/jsr-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,18 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Sync version to jsr.jsonc
run: |
node -e "
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Using ' single quotes outside and " double quotes inside would be clearer, and help ensure that ` or $ characters aren't assigned a bash meaning.

const fs = require('fs');
const pkgVersion = require('./package.json').version;
let text = fs.readFileSync('jsr.jsonc', 'utf8');

text = text.replace(
/(\"version\"\s*:\s*\")([^\"]+)(\")/,
\`$1\${pkgVersion}$3\`
Comment on lines +27 to +28
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

A lookbehind assertion would simplify things here.

Suggested change
/(\"version\"\s*:\s*\")([^\"]+)(\")/,
\`$1\${pkgVersion}$3\`
/(?<="version"\s*:\s*")[^\"]+/,
pkgVersion

);

fs.writeFileSync('jsr.jsonc', text);
"
- run: npx jsr publish