-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New: Add option to ignore skip of prerelease (#7)
- Loading branch information
Showing
10 changed files
with
127 additions
and
17 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 |
---|---|---|
|
@@ -2,7 +2,6 @@ name: Test | |
|
||
on: | ||
pull_request: | ||
push: | ||
branches: | ||
- '**' | ||
|
||
|
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,13 @@ | ||
const pluginConfigDefaults = { | ||
includePrerelease: false, | ||
customTags: ['v${major}'], | ||
}; | ||
|
||
const preparePluginConfig = (pluginConfig: unknown) => ({ | ||
...pluginConfigDefaults, | ||
...(pluginConfig ? pluginConfig : {}), | ||
}); | ||
|
||
export type PluginConfigType = ReturnType<typeof preparePluginConfig>; | ||
|
||
export default preparePluginConfig; |
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,75 @@ | ||
import preparePluginConfig from './preparePluginConfig'; | ||
import skipForPrerelease from './skipForPrerelease'; | ||
|
||
describe('skipForPrerelease', () => { | ||
it('returns correctly when ignore prerelease skip config set', () => { | ||
expect( | ||
skipForPrerelease( | ||
{ | ||
name: 'example-branch', | ||
prerelease: 'beta', | ||
}, | ||
preparePluginConfig({ includePrerelease: true }) | ||
) | ||
).toBe(false); | ||
}); | ||
|
||
it('returns correctly when branch is not a prerelease', () => { | ||
expect( | ||
skipForPrerelease( | ||
{ | ||
name: 'example-branch', | ||
}, | ||
preparePluginConfig({}) | ||
) | ||
).toBe(false); | ||
}); | ||
|
||
it('returns correctly when prerelease set to empty string', () => { | ||
expect( | ||
skipForPrerelease( | ||
{ | ||
name: 'example-branch', | ||
prerelease: '', | ||
}, | ||
preparePluginConfig({}) | ||
) | ||
).toBe(false); | ||
}); | ||
|
||
it('returns correctly when prerelease set to string', () => { | ||
expect( | ||
skipForPrerelease( | ||
{ | ||
name: 'example-branch', | ||
prerelease: 'beta', | ||
}, | ||
preparePluginConfig({}) | ||
) | ||
).toBe(true); | ||
}); | ||
|
||
it('returns correctly when prerelease set to true boolean', () => { | ||
expect( | ||
skipForPrerelease( | ||
{ | ||
name: 'example-branch', | ||
prerelease: true, | ||
}, | ||
preparePluginConfig({}) | ||
) | ||
).toBe(true); | ||
}); | ||
|
||
it('returns correctly when prerelease set to false boolean', () => { | ||
expect( | ||
skipForPrerelease( | ||
{ | ||
name: 'example-branch', | ||
prerelease: false, | ||
}, | ||
preparePluginConfig({}) | ||
) | ||
).toBe(false); | ||
}); | ||
}); |
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 @@ | ||
import type { BranchObject } from 'semantic-release'; | ||
|
||
import type { PluginConfigType } from './preparePluginConfig'; | ||
|
||
const isPrerelease = (branchObject: BranchObject) => !!branchObject?.prerelease; | ||
|
||
const skipForPrerelease = ( | ||
branch: BranchObject, | ||
pluginConfig: PluginConfigType | ||
): boolean => { | ||
if (pluginConfig.includePrerelease === true) return false; | ||
|
||
return isPrerelease(branch); | ||
}; | ||
|
||
export default skipForPrerelease; |
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 was deleted.
Oops, something went wrong.
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