Skip to content

Commit

Permalink
Added cwd input option (#134)
Browse files Browse the repository at this point in the history
* feat: add cwd for projects that not in the root directory

* docs: add cwd to README

* reword the added log

* tweak changeset

Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com>
  • Loading branch information
dmregister and Andarist authored Jan 23, 2022
1 parent 5c0997b commit 1ed9bc2
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/kind-apes-exist.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@changesets/action": minor
---

Added `cwd` input option that can be used in projects that are not in the root directory.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ This action for [Changesets](https://github.com/atlassian/changesets) creates a
- commit - The commit message to use. Default to `Version Packages`
- title - The pull request title. Default to `Version Packages`
- setupGitUser - Sets up the git user for commits as `"github-actions[bot]"`. Default to `true`
- cwd - Changes node's `process.cwd()` if the project is not located on the root. Default to `process.cwd()`

### Outputs

Expand Down
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ inputs:
version:
description: "The command to update version, edit CHANGELOG, read and delete changesets. Default to `changeset version` if not provided"
required: false
cwd:
description: Sets the cwd for the node process. Default to `process.cwd()`
required: false
commit:
description: |
The commit message. Default to `Version Packages`
Expand Down
8 changes: 7 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const getOptionalInput = (name: string) => core.getInput(name) || undefined;
return;
}

let setupGitUser = core.getBooleanInput('setupGitUser');
let setupGitUser = core.getBooleanInput("setupGitUser");

if (setupGitUser) {
console.log("setting git user");
Expand All @@ -27,6 +27,12 @@ const getOptionalInput = (name: string) => core.getInput(name) || undefined;
`machine github.com\nlogin github-actions[bot]\npassword ${githubToken}`
);

const inputCwd = core.getInput("cwd");
if (inputCwd) {
console.log("changing directory to the one given as the input");
process.chdir(inputCwd);
}

let { changesets } = await readChangesetState();

let publishScript = core.getInput("publish");
Expand Down

0 comments on commit 1ed9bc2

Please sign in to comment.