♻️ Use MacRunner

This commit is contained in:
Yann Bertrand 2022-08-19 15:37:37 +02:00
parent b34945d0b1
commit dafc00ed8a

View file

@ -1,22 +1,30 @@
const delay = require('delay')
const robot = require('robotjs')
const { captureImage, compressPngImage } = require('../utils')
const MacRunner = require('../mac-runner')
const { compressPngImage } = require('../utils')
module.exports = {
run: async (outputPath) => {
console.log('> Recording dock readme screenshot')
// Preparation
const { width, height } = robot.getScreenSize()
const screenshot = `${outputPath}/dock-tmp.png`
try {
const { screenWidth, screenHeight } = MacRunner.getScreenSize()
const dockHeight = MacRunner.getDockHeight()
await delay(2000)
// Screenshot
captureImage(0, height - 80, width, 80).write(screenshot)
const runner = new MacRunner()
await runner
.captureScreenRect(
0,
screenHeight - dockHeight,
screenWidth,
dockHeight,
`${outputPath}/dock-tmp.png`
)
.run()
} catch (runnerError) {
throw new Error(runnerError)
}
try {
await compressPngImage(screenshot, outputPath, 'dock')
await compressPngImage(`${outputPath}/dock-tmp.png`, outputPath, 'dock')
} catch (compressPngImageError) {
throw new Error(compressPngImageError)
}