Skip to content

Commit

Permalink
dont return paths for unchanged packages (#418)
Browse files Browse the repository at this point in the history
Co-authored-by: Mitchell Hamilton <mitchell@hamil.town>
  • Loading branch information
jonathanmorley and emmatown committed Aug 10, 2020
1 parent 868eb1e commit 1dd3117
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/curvy-ducks-end.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@changesets/git": patch
---

Don't return paths for unchanged packages
17 changes: 14 additions & 3 deletions packages/git/src/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,13 +208,24 @@ describe("git", () => {
await commit("added packageA package.json", cwd);
});

it("should be empty if no changes", async () => {
it("should be empty if no changes (partial path)", async () => {
const head = await spawn("git", ["rev-parse", "HEAD"], { cwd });
const changedFiles = await getChangedFilesSince({
ref: head.stdout.toString().trim(),
cwd
cwd,
fullPath: false
});
expect(changedFiles).toHaveLength(0);
});

it("should be empty if no changes (full path)", async () => {
const head = await spawn("git", ["rev-parse", "HEAD"], { cwd });
const changedFiles = await getChangedFilesSince({
ref: head.stdout.toString().trim(),
cwd,
fullPath: true
});
expect(changedFiles.filter(a => a)).toHaveLength(0);
expect(changedFiles).toHaveLength(0);
});

it("should get list of files that have been committed", async () => {
Expand Down
3 changes: 2 additions & 1 deletion packages/git/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ async function getChangedFilesSince({
const files = cmd.stdout
.toString()
.trim()
.split("\n");
.split("\n")
.filter(a => a);
if (!fullPath) return files;
return files.map(file => path.resolve(cwd, file));
}
Expand Down

0 comments on commit 1dd3117

Please sign in to comment.