macos-defaults/record/screenshots/disable-shadow/false.js

37 lines
1 KiB
JavaScript
Raw Normal View History

2022-08-18 09:02:00 +00:00
const MacRunner = require('../../mac-runner')
const { compressPngImage } = require('../../utils')
module.exports = {
run: async (outputPath) => {
2022-08-18 09:02:00 +00:00
console.log(
'> Recording screencapture disable-shadow with param set to false'
2020-11-27 12:45:16 +00:00
)
2022-08-18 09:02:00 +00:00
try {
const runner = new MacRunner()
await runner
.openApp('Safari', '-F https://apple.com')
.activateApp('Safari')
.moveAndResizeApp('Safari', 0, 0, 740 * 2, 413 * 2)
// We do not set the default as `captureApp` takes a param to disable shadow
.captureApp('Safari', `${outputPath}/false-tmp.png`, false)
.killApp('Safari')
.run()
} catch (runnerError) {
logRollbackInfo()
2022-08-18 09:02:00 +00:00
throw new Error(runnerError)
}
try {
2022-08-18 09:02:00 +00:00
await compressPngImage(`${outputPath}/false-tmp.png`, outputPath, 'false')
} catch (compressPngImageError) {
logRollbackInfo()
throw new Error(compressPngImageError)
}
2022-08-18 09:02:00 +00:00
return { filepath: `${outputPath}/false` }
2020-11-27 12:45:16 +00:00
},
}
2022-08-18 09:02:00 +00:00
function logRollbackInfo() {}