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