From 9c239c23c96dd875d2bbb5908a411c06e207f5cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20B=C3=BCchele?= Date: Tue, 7 Aug 2018 06:32:07 -0700 Subject: [PATCH] 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 --- static/index.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/static/index.js b/static/index.js index faff72c7a..2ba20048a 100644 --- a/static/index.js +++ b/static/index.js @@ -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)) {