macos-defaults/record/dock
Yann Bertrand 8bca39f739 ♻️ Use MacRunner
2022-08-18 11:08:08 +02:00
..
autohide-delay 🐛 Add delay in commands 2021-12-20 18:55:06 +01:00
autohide-time-modifier 🐛 Add delay in commands 2021-12-20 18:55:06 +01:00
mineffect 🚨 Run Prettier 2020-11-27 14:39:16 +01:00
orientation ♻️ Add a killApp record command 2021-12-20 20:58:38 +01:00
show-recents 🐛 Catch another error to display rollback info 2021-12-20 21:00:42 +01:00
tilesize ♻️ Use MacRunner 2022-08-18 11:08:08 +02:00
readme.js 🚨 Run Prettier 2020-11-27 14:39:16 +01:00

const delay = require('delay')
const robot = require('robotjs')
const { captureImage, 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`

    await delay(2000)

    // Screenshot
    captureImage(0, height - 80, width, 80).write(screenshot)

    try {
      await compressPngImage(screenshot, outputPath, 'dock')
    } catch (compressPngImageError) {
      throw new Error(compressPngImageError)
    }

    return { filepath: `${outputPath}/dock` }
  },
}