-
Notifications
You must be signed in to change notification settings - Fork 129
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: use branch prerelease property for detection (#863)
* feat: use branch prerelease property for detection * Update lib/is-prerelease.js Co-authored-by: Gregor Martynus <39992+gr2m@users.noreply.github.com> --------- Co-authored-by: Olabode Lawal-Shittabey <babblebey@gmail.com> Co-authored-by: Gregor Martynus <39992+gr2m@users.noreply.github.com>
- Loading branch information
1 parent
c31876b
commit 45b8da9
Showing
2 changed files
with
62 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,11 @@ | ||
export default function isPrerelease({ type, main }) { | ||
return type === "prerelease" || (type === "release" && !main); | ||
export default function isPrerelease({ type, main, prerelease }) { | ||
if (prerelease === false) { | ||
return false; | ||
} | ||
return ( | ||
type === "prerelease" || | ||
(type === "release" && !main) || | ||
typeof prerelease == "string" || | ||
prerelease === 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import test from "ava"; | ||
import isPrerelease from "../lib/is-prerelease.js"; | ||
|
||
test("Test for empty object", (t) => { | ||
const branch = {}; | ||
t.is(isPrerelease(branch), false); | ||
}); | ||
|
||
test("Test if prerelease true property as boolean is used correctly", (t) => { | ||
const branch = { | ||
prerelease: true, | ||
}; | ||
t.is(isPrerelease(branch), true); | ||
}); | ||
|
||
test("Test if prerelease false property as boolean is used correctly", (t) => { | ||
const branch = { | ||
prerelease: false, | ||
}; | ||
t.is(isPrerelease(branch), false); | ||
}); | ||
|
||
test("Test if prerelease property as string is used correctly", (t) => { | ||
const branch = { | ||
prerelease: "rc", | ||
}; | ||
t.is(isPrerelease(branch), true); | ||
}); | ||
|
||
test("Test if prerelease type is used correctly", (t) => { | ||
const branch = { | ||
type: "prerelease", | ||
}; | ||
t.is(isPrerelease(branch), true); | ||
}); | ||
|
||
test("Test if prerelease type and main is used correctly", (t) => { | ||
const branch = { | ||
type: "release", | ||
main: false, | ||
}; | ||
t.is(isPrerelease(branch), true); | ||
}); | ||
|
||
test("Test if prerelease type and main in addition to prerelease is used correctly", (t) => { | ||
const branch = { | ||
type: "release", | ||
main: false, | ||
prerelease: false, | ||
}; | ||
t.is(isPrerelease(branch), false); | ||
}); |