Skip to content

Update package metadata reading method in GitHub Actions workflow#14

Merged
kasuken merged 1 commit into
mainfrom
githubaction
Sep 8, 2025
Merged

Update package metadata reading method in GitHub Actions workflow#14
kasuken merged 1 commit into
mainfrom
githubaction

Conversation

@kasuken
Copy link
Copy Markdown
Owner

@kasuken kasuken commented Sep 8, 2025

Refactor the method for reading package metadata in the GitHub Actions workflow to improve efficiency and clarity.

Copilot AI review requested due to automatic review settings September 8, 2025 17:15
@kasuken kasuken self-assigned this Sep 8, 2025
@kasuken kasuken added the bug Something isn't working label Sep 8, 2025
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors the GitHub Actions workflow to read package metadata using a single Node.js command instead of multiple echo statements, aiming to improve efficiency and reduce redundant file operations.

  • Consolidates three separate Node.js commands into one comprehensive script
  • Uses fs.appendFileSync() to write directly to GITHUB_OUTPUT instead of shell redirection
  • Maintains the same output variables (version, name, vsix) for downstream workflow steps

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

echo "version=$(node -p \"require('./package.json').version\")" >> "$GITHUB_OUTPUT"
echo "name=$(node -p \"require('./package.json').name\")" >> "$GITHUB_OUTPUT"
echo "vsix=$(node -p \"const p=require('./package.json'); p.name + '-' + p.version + '.vsix'\")" >> "$GITHUB_OUTPUT"
node -e "const fs=require('fs'); const p=require('./package.json'); const out=process.env.GITHUB_OUTPUT; fs.appendFileSync(out, `version=${p.version}\n`); fs.appendFileSync(out, `name=${p.name}\n`); fs.appendFileSync(out, `vsix=${p.name}-${p.version}.vsix\n`);"
Copy link

Copilot AI Sep 8, 2025

Choose a reason for hiding this comment

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

[nitpick] This single-line command is difficult to read and maintain. Consider breaking it into multiple lines or using a here document for better readability.

Suggested change
node -e "const fs=require('fs'); const p=require('./package.json'); const out=process.env.GITHUB_OUTPUT; fs.appendFileSync(out, `version=${p.version}\n`); fs.appendFileSync(out, `name=${p.name}\n`); fs.appendFileSync(out, `vsix=${p.name}-${p.version}.vsix\n`);"
node <<'EOF'
const fs = require('fs');
const p = require('./package.json');
const out = process.env.GITHUB_OUTPUT;
fs.appendFileSync(out, `version=${p.version}\n`);
fs.appendFileSync(out, `name=${p.name}\n`);
fs.appendFileSync(out, `vsix=${p.name}-${p.version}.vsix\n`);
EOF

Copilot uses AI. Check for mistakes.
echo "version=$(node -p \"require('./package.json').version\")" >> "$GITHUB_OUTPUT"
echo "name=$(node -p \"require('./package.json').name\")" >> "$GITHUB_OUTPUT"
echo "vsix=$(node -p \"const p=require('./package.json'); p.name + '-' + p.version + '.vsix'\")" >> "$GITHUB_OUTPUT"
node -e "const fs=require('fs'); const p=require('./package.json'); const out=process.env.GITHUB_OUTPUT; fs.appendFileSync(out, `version=${p.version}\n`); fs.appendFileSync(out, `name=${p.name}\n`); fs.appendFileSync(out, `vsix=${p.name}-${p.version}.vsix\n`);"
Copy link

Copilot AI Sep 8, 2025

Choose a reason for hiding this comment

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

Missing input validation for package.json properties. If p.version or p.name contain special characters or newlines, they could corrupt the GITHUB_OUTPUT format.

Suggested change
node -e "const fs=require('fs'); const p=require('./package.json'); const out=process.env.GITHUB_OUTPUT; fs.appendFileSync(out, `version=${p.version}\n`); fs.appendFileSync(out, `name=${p.name}\n`); fs.appendFileSync(out, `vsix=${p.name}-${p.version}.vsix\n`);"
node -e "const fs=require('fs'); const p=require('./package.json'); const out=process.env.GITHUB_OUTPUT; const esc=s=>s.replace(/%/g,'%25').replace(/\\n/g,'%0A').replace(/\\r/g,'%0D'); fs.appendFileSync(out, `version=${esc(p.version)}\n`); fs.appendFileSync(out, `name=${esc(p.name)}\n`); fs.appendFileSync(out, `vsix=${esc(p.name)}-${esc(p.version)}.vsix\n`);"

Copilot uses AI. Check for mistakes.
@kasuken kasuken merged commit 7fa9cd6 into main Sep 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants