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 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)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue