2020-11-13 17:08:12 +00:00
|
|
|
const MacRunner = require('../../mac-runner')
|
2020-11-13 14:30:12 +00:00
|
|
|
const { compressPngImage } = require('../../utils')
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
run: async (outputPath) => {
|
2020-11-13 17:08:12 +00:00
|
|
|
console.log('> Recording finder show hidden files to false')
|
2020-11-13 14:30:12 +00:00
|
|
|
|
|
|
|
try {
|
2020-11-13 17:08:12 +00:00
|
|
|
const runner = new MacRunner()
|
2020-11-13 14:30:12 +00:00
|
|
|
await runner
|
2022-08-19 11:58:14 +00:00
|
|
|
.setDefault('com.apple.finder', 'AppleShowAllFiles', '-bool false', '0')
|
2021-12-20 19:58:38 +00:00
|
|
|
.killApp('Finder')
|
2022-08-18 15:52:05 +00:00
|
|
|
.wait(1000)
|
2020-11-13 14:30:12 +00:00
|
|
|
.openApp('Finder', '~')
|
2022-08-18 15:52:05 +00:00
|
|
|
.activateApp('Finder')
|
|
|
|
.moveAndResizeApp('Finder', 0, 0, 740, 400)
|
2020-11-13 14:30:12 +00:00
|
|
|
.captureApp('Finder', `${outputPath}/false.png`)
|
2022-08-19 11:58:14 +00:00
|
|
|
.deleteDefault('com.apple.finder', 'AppleShowAllFiles')
|
2021-12-20 19:58:38 +00:00
|
|
|
.killApp('Finder')
|
2020-11-13 17:08:12 +00:00
|
|
|
.run()
|
2020-11-13 14:30:12 +00:00
|
|
|
} catch (runnerError) {
|
2020-11-13 17:08:12 +00:00
|
|
|
logRollbackInfo()
|
|
|
|
throw new Error(runnerError)
|
2020-11-13 14:30:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
|
|
await compressPngImage(`${outputPath}/false.png`, outputPath, 'false')
|
|
|
|
} catch (compressPngImageError) {
|
|
|
|
logRollbackInfo()
|
|
|
|
throw new Error(compressPngImageError)
|
|
|
|
}
|
|
|
|
|
|
|
|
return { filepath: `${outputPath}/false` }
|
|
|
|
},
|
2020-11-13 17:08:12 +00:00
|
|
|
}
|
2020-11-13 14:30:12 +00:00
|
|
|
|
|
|
|
function logRollbackInfo() {
|
2020-11-27 12:45:16 +00:00
|
|
|
console.info(
|
|
|
|
'Please manually run this command to make sure everything is properly reset:'
|
|
|
|
)
|
|
|
|
console.info(
|
2022-08-19 11:58:14 +00:00
|
|
|
'defaults delete com.apple.finder AppleShowAllFiles && killall Finder'
|
2020-11-27 12:45:16 +00:00
|
|
|
)
|
2020-11-13 14:30:12 +00:00
|
|
|
}
|