mirror of
https://github.com/yannbertrand/macos-defaults
synced 2024-12-15 14:12:30 +00:00
♻️ Use MacRunner
This commit is contained in:
parent
b34945d0b1
commit
dafc00ed8a
1 changed files with 19 additions and 11 deletions
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue