-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
177 additions
and
9 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
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,41 @@ | ||
export const consoleImage = function (url: string) { | ||
const image = new Image(); | ||
image.onload = function (this: any) { | ||
// @ts-ignore | ||
const isChromium = navigator.userAgent.match(/chrome|chromium|crios/i) && !!window.chrome; | ||
const style = [ | ||
'font-size: 0px;', | ||
!isChromium ? `line-height: ${this.height}px;` : '', | ||
`padding: ${this.height / 2}px ${this.width / 2}px;`, | ||
`background: url(${url}) center center no-repeat;`, | ||
'background-size: contain;', | ||
].join(' '); | ||
console.log('%c ', style); | ||
}; | ||
image.src = url; | ||
}; | ||
|
||
/** | ||
* 获取图片,并转 base64 | ||
* | ||
* @param url 图片链接 | ||
* @returns 获取结果 | ||
* @example | ||
* ```ts | ||
* getBase64FromUrl(imgUrl).then(consoleImage); | ||
* ``` | ||
*/ | ||
export async function getBase64FromUrl(url: string) { | ||
const data = await fetch(url); | ||
const blob = await data.blob(); | ||
return new Promise((resolve, reject) => { | ||
const reader = new FileReader(); | ||
reader.readAsDataURL(blob); | ||
reader.onloadend = () => { | ||
const base64data = reader.result; | ||
resolve(base64data); | ||
}; | ||
reader.onerror = reject; | ||
}); | ||
} | ||
|
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,4 @@ | ||
export { | ||
consoleImage, | ||
getBase64FromUrl, | ||
} from './image'; |
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,5 @@ | ||
export const DEFAULT_WHITE_REG = /^release|develop|hotfix\/.+$/; | ||
|
||
export function shouldInclude(branch = '', reg = DEFAULT_WHITE_REG) { | ||
return !reg.test(branch); | ||
} |
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
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 @@ | ||
import { shouldInclude } from '../../src/daily-merge/helper'; | ||
|
||
describe('shouldExclude', () => { | ||
it('shouldExclude', () => { | ||
expect(shouldInclude('release')).toBe(false); | ||
expect(shouldInclude('develop')).toBe(false); | ||
expect(shouldInclude('hotfix/abc-adf-123')).toBe(false); | ||
|
||
expect(shouldInclude('feature/manager-hp')).toBe(true); | ||
expect(shouldInclude('123123-a')).toBe(true); | ||
expect(shouldInclude('abc-d')).toBe(true); | ||
}); | ||
}); |