2022-08-19 15:37:37 +02:00
|
|
|
const MacRunner = require('../mac-runner')
|
|
|
|
const { compressPngImage } = require('../utils')
|
2020-09-05 21:28:16 +02:00
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
run: async (outputPath) => {
|
|
|
|
console.log('> Recording dock readme screenshot')
|
|
|
|
|
2022-08-19 15:37:37 +02:00
|
|
|
try {
|
|
|
|
const { screenWidth, screenHeight } = MacRunner.getScreenSize()
|
|
|
|
const dockHeight = MacRunner.getDockHeight()
|
2020-09-05 21:28:16 +02:00
|
|
|
|
2022-08-19 15:37:37 +02:00
|
|
|
const runner = new MacRunner()
|
|
|
|
await runner
|
|
|
|
.captureScreenRect(
|
|
|
|
0,
|
|
|
|
screenHeight - dockHeight,
|
|
|
|
screenWidth,
|
|
|
|
dockHeight,
|
|
|
|
`${outputPath}/dock-tmp.png`
|
|
|
|
)
|
|
|
|
.run()
|
|
|
|
} catch (runnerError) {
|
|
|
|
throw new Error(runnerError)
|
|
|
|
}
|
2020-09-05 21:28:16 +02:00
|
|
|
|
|
|
|
try {
|
2022-08-19 15:37:37 +02:00
|
|
|
await compressPngImage(`${outputPath}/dock-tmp.png`, outputPath, 'dock')
|
2020-09-05 21:28:16 +02:00
|
|
|
} catch (compressPngImageError) {
|
|
|
|
throw new Error(compressPngImageError)
|
|
|
|
}
|
|
|
|
|
|
|
|
return { filepath: `${outputPath}/dock` }
|
2020-11-27 13:45:16 +01:00
|
|
|
},
|
2020-09-05 21:28:16 +02:00
|
|
|
}
|