add spotlight comment with old name

Summary:
To make the transition from the old to the new name as smooth as possible, we want to allow people to launch the app using its old name via Spotlight.
Therefore, we set a comment on the executable with the old name. These comments are indexed by Spotlight and the app can be launched with the old name.

Reviewed By: passy, priteshrnandgaonkar

Differential Revision: D9149323

fbshipit-source-id: b812776350b3fc57dc3a193bcd96c343a13a039f
This commit is contained in:
Daniel Büchele
2018-08-07 06:32:07 -07:00
committed by Facebook Github Bot
parent f73c28ba6b
commit 9c239c23c9

View File

@@ -8,6 +8,7 @@ const {app, BrowserWindow} = require('electron');
const path = require('path');
const url = require('url');
const fs = require('fs');
const {exec} = require('child_process');
const compilePlugins = require('./compilePlugins.js');
const os = require('os');
@@ -15,6 +16,21 @@ if (!process.env.ANDROID_HOME) {
process.env.ANDROID_HOME = '/opt/android_sdk';
}
if (process.platform === 'darwin') {
// If we are running on macOS and the app is called Flipper, we add a comment
// with the old name, to make it findable via Spotlight using its old name.
const APP_NAME = 'Flipper.app';
const i = process.execPath.indexOf(`/${APP_NAME}/`);
if (i > -1) {
exec(
`osascript -e 'on run {f, c}' -e 'tell app "Finder" to set comment of (POSIX file f as alias) to c' -e end "${process.execPath.substr(
0,
i,
)}/${APP_NAME}" "sonar"`,
);
}
}
// ensure .sonar folder and config exist
const sonarDir = path.join(os.homedir(), '.sonar');
if (!fs.existsSync(sonarDir)) {