macos-defaults/record/dock
2022-08-19 15:38:29 +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 Improve some Dock screenshots 2022-08-19 15:38:29 +02:00
tilesize ♻️ Use MacRunner 2022-08-18 11:08:08 +02:00
readme.js ♻️ Use MacRunner 2022-08-19 15:37:37 +02:00

const MacRunner = require('../mac-runner')
const { compressPngImage } = require('../utils')

module.exports = {
  run: async (outputPath) => {
    console.log('> Recording dock readme screenshot')

    try {
      const { screenWidth, screenHeight } = MacRunner.getScreenSize()
      const dockHeight = MacRunner.getDockHeight()

      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(`${outputPath}/dock-tmp.png`, outputPath, 'dock')
    } catch (compressPngImageError) {
      throw new Error(compressPngImageError)
    }

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