-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(publish): Exit early when publishing w/o commits (#1453)
Lerna will throw an error, when publishing the current project and there are no commits at all. This change will check if there are any commits before proceeding with the publish command. - Refactor the fixtures as preparation for tests with/without commit - Add check if any commits are present - Add tests for this behaviour Closes #773.
- Loading branch information
1 parent
6961388
commit 6cbae35
Showing
6 changed files
with
79 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
"use strict"; | ||
|
||
const execa = require("execa"); | ||
const initFixture = require("@lerna-test/init-fixture")(__dirname); | ||
const isAnythingCommited = require("../lib/is-anything-commited"); | ||
|
||
test("isAnythingCommited", async () => { | ||
const cwd = await initFixture("root-manifest-only"); | ||
|
||
expect(isAnythingCommited({ cwd })).toBe(true); | ||
}); | ||
|
||
test("isAnythingCommited without and with a commit", async () => { | ||
const cwd = await initFixture("root-manifest-only", false); | ||
|
||
expect(isAnythingCommited({ cwd })).toBe(false); | ||
|
||
await execa("git", ["commit", "--allow-empty", "-m", "change"], { cwd }); | ||
|
||
expect(isAnythingCommited({ cwd })).toBe(true); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
"use strict"; | ||
|
||
const log = require("npmlog"); | ||
const childProcess = require("@lerna/child-process"); | ||
|
||
module.exports = isAnythingCommited; | ||
|
||
function isAnythingCommited(opts) { | ||
log.silly("isAnythingCommited"); | ||
|
||
const anyCommits = childProcess.execSync("git", ["rev-list", "--count", "--all", "--max-count=1"], opts); | ||
|
||
log.verbose("isAnythingCommited", anyCommits); | ||
|
||
return Boolean(parseInt(anyCommits, 10)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters