Skip to content

Commit

Permalink
Add a working directory option (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
microbit-matt-hillsdon authored Jun 5, 2024
1 parent 9977605 commit c4b41a6
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 3 deletions.
6 changes: 5 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ description:
'Sets a semver package version based on the existing version and the
branch/tag/build number'
author: 'Micro:bit Educational Foundation'

inputs:
working-directory:
description: 'Working directory for this step'
required: false
default: '.'
runs:
using: node20
main: dist/index.js
2 changes: 1 addition & 1 deletion badges/coverage.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ import { contextFromEnvironment, generateVersion } from './version'
*/
export async function run(): Promise<void> {
try {
// Unfortunately "uses" steps aren't affected by the job-wide working-directory
// setting so we add our own.
const workingDirectory = core.getInput('working-directory')
if (workingDirectory) {
process.chdir(workingDirectory)
}

const packageJsonPath = 'package.json'
const packageJson = JSON.parse(
fs.readFileSync(packageJsonPath, { encoding: 'utf-8' })
Expand Down

0 comments on commit c4b41a6

Please sign in to comment.