Add finder AppleShowAllFiles command

This commit is contained in:
Benjamin Petetot 2020-11-13 15:30:12 +01:00 committed by Yann Bertrand
parent 15801e65ce
commit 35745a034a
6 changed files with 114 additions and 0 deletions

View file

@ -316,6 +316,27 @@ categories:
text: Afficher toutes les extensions de fichier dans le Finder
versions: [Big Sur, Catalina, Mojave]
after: killall Finder
- key: AppleShowAllFiles
domain: com.apple.Finder
title: Afficher les fichiers cachés
description: Afficher les fichiers cachés dans le Finder.
param:
type: bool
examples:
- value: false
text: Ne pas afficher les fichiers cachés dans le Finder
image:
filename: "false.png"
width: 740
height: 451
- value: true
text: Afficher les fichiers cachés dans le Finder
image:
filename: "true.png"
width: 740
height: 451
versions: [Catalina]
after: killall Finder
- key: FXEnableExtensionChangeWarning
domain: com.apple.finder
title: Alerte au changement d'extension

View file

@ -317,6 +317,27 @@ categories:
text: Show all file extensions inside the Finder
versions: [Big Sur, Catalina, Mojave]
after: killall Finder
- key: AppleShowAllFiles
domain: com.apple.Finder
title: Show hidden files
description: Show hidden files in the Finder.
param:
type: bool
examples:
- value: false
text: Do not show hidden files inside the Finder
image:
filename: "false.png"
width: 740
height: 451
- value: true
text: Show hidden files inside the Finder
image:
filename: "true.png"
width: 740
height: 451
versions: [Catalina]
after: killall Finder
- key: FXEnableExtensionChangeWarning
domain: com.apple.finder
title: Changing file extension warning

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

View file

@ -0,0 +1,36 @@
const path = require('path');
const MacRunner = require('../../mac-runner');
const { compressPngImage } = require('../../utils')
module.exports = {
run: async (outputPath) => {
console.log('> Recording finder show hidden files to false');
try {
const runner = new MacRunner();
await runner
.setDefault('com.apple.Finder', 'AppleShowAllFiles', '-bool false', 'killall Finder')
.openApp('Finder', '~')
.captureApp('Finder', `${outputPath}/false.png`)
.deleteDefault('com.apple.Finder', 'AppleShowAllFiles', 'killall Finder')
.run();
} catch (runnerError) {
logRollbackInfo();
throw new Error(runnerError);
}
try {
await compressPngImage(`${outputPath}/false.png`, outputPath, 'false')
} catch (compressPngImageError) {
logRollbackInfo()
throw new Error(compressPngImageError)
}
return { filepath: `${outputPath}/false` }
},
};
function logRollbackInfo() {
console.info('Please manually run this command to make sure everything is properly reset:')
console.info('defaults delete com.apple.Finder AppleShowAllFiles && killall Finder')
}

View file

@ -0,0 +1,36 @@
const path = require('path');
const MacRunner = require('../../mac-runner');
const { compressPngImage } = require('../../utils')
module.exports = {
run: async (outputPath) => {
console.log('> Recording finder show hidden files to true');
try {
const runner = new MacRunner();
await runner
.setDefault('com.apple.Finder', 'AppleShowAllFiles', '-bool true', 'killall Finder')
.openApp('Finder', '~')
.captureApp('Finder', `${outputPath}/true.png`)
.deleteDefault('com.apple.Finder', 'AppleShowAllFiles', 'killall Finder')
.run();
} catch (runnerError) {
logRollbackInfo();
throw new Error(runnerError);
}
try {
await compressPngImage(`${outputPath}/true.png`, outputPath, 'true')
} catch (compressPngImageError) {
logRollbackInfo()
throw new Error(compressPngImageError)
}
return { filepath: `${outputPath}/true` }
},
};
function logRollbackInfo() {
console.info('Please manually run this command to make sure everything is properly reset:')
console.info('defaults delete com.apple.Finder AppleShowAllFiles && killall Finder')
}