@@ -7,14 +7,13 @@ const { spawnSync } = require('child_process');
77
88const ROOT = path . resolve ( __dirname , '..' , '..' ) ;
99const DEFAULT_SOURCE_APP = path . join ( ROOT , 'byoe/node_modules/electron/dist/Electron.app' ) ;
10- const SLACK_RESOURCES = '/Applications/Slack.app/Contents/Resources' ;
11- const SLACK_ASAR = path . join ( SLACK_RESOURCES , 'app.asar' ) ;
1210const ENTITLEMENTS = path . join ( ROOT , 'scripts/release/entitlements.plist' ) ;
1311const DEFAULTS = {
1412 target : '/tmp/slick/Slick.app' ,
1513 profile : '/tmp/slick/profile' ,
1614 appVersion : '1.0.0' ,
1715 buildNumber : '0' ,
16+ slackApp : '/Applications/Slack.app' ,
1817 sourceApp : process . env . SLICK_SOURCE_APP || DEFAULT_SOURCE_APP ,
1918 force : false ,
2019 allowNonTmp : false ,
@@ -24,13 +23,15 @@ function usage() {
2423 console . error ( `Usage:
2524 node scripts/byoe/build-handoff-app.js [--target <app>] [--profile <dir>] [--app-version <x.y.z>]
2625 [--build-number <n>]
26+ [--slack-app <Slack.app>]
2727 [--source-app <Electron.app>] [--force] [--allow-non-tmp]
2828
2929Defaults:
3030 --target ${ DEFAULTS . target }
3131 --profile ${ DEFAULTS . profile }
3232 --app-version ${ DEFAULTS . appVersion }
3333 --build-number ${ DEFAULTS . buildNumber }
34+ --slack-app ${ DEFAULTS . slackApp }
3435 --source-app ${ DEFAULTS . sourceApp } ` ) ;
3536 process . exit ( 2 ) ;
3637}
@@ -42,6 +43,7 @@ function parseArgs(argv) {
4243 else if ( argv [ i ] === '--profile' ) o . profile = argv [ ++ i ] || usage ( ) ;
4344 else if ( argv [ i ] === '--app-version' ) o . appVersion = argv [ ++ i ] || usage ( ) ;
4445 else if ( argv [ i ] === '--build-number' ) o . buildNumber = argv [ ++ i ] || usage ( ) ;
46+ else if ( argv [ i ] === '--slack-app' ) o . slackApp = argv [ ++ i ] || usage ( ) ;
4547 else if ( argv [ i ] === '--source-app' ) o . sourceApp = argv [ ++ i ] || usage ( ) ;
4648 else if ( argv [ i ] === '--force' ) o . force = true ;
4749 else if ( argv [ i ] === '--allow-non-tmp' ) o . allowNonTmp = true ;
@@ -179,17 +181,23 @@ const { app, dialog, shell, Menu, MenuItem } = require('electron');
179181const SLICK_ROOT = path.join(process.resourcesPath, 'slick');
180182const PROFILE = process.env.SLICK_HANDOFF_PROFILE || path.join(app.getPath('appData'), 'Slick');
181183const DEFAULT_THEME = ${ JSON . stringify ( defaultTheme ) } ;
182- const SLACK_RESOURCES = ${ JSON . stringify ( SLACK_RESOURCES ) } ;
183- const SLACK_ASAR = ${ JSON . stringify ( SLACK_ASAR ) } ;
184+ const DEFAULT_SLACK_APP = ${ JSON . stringify ( path . resolve ( opts . slackApp ) ) } ;
185+ const SLACK_PATH_CONFIG = path.join(PROFILE, 'slick', 'slack-app-path');
186+ let SLACK_APP = DEFAULT_SLACK_APP;
187+ try {
188+ SLACK_APP = fs.readFileSync(SLACK_PATH_CONFIG, 'utf8').trim() || DEFAULT_SLACK_APP;
189+ } catch {}
190+ const SLACK_RESOURCES = path.join(SLACK_APP, 'Contents', 'Resources');
191+ const SLACK_ASAR = path.join(SLACK_RESOURCES, 'app.asar');
184192const SLICK_VERSION = ${ JSON . stringify ( opts . appVersion ) } ;
185193const SLICK_BUILD = parseInt(${ JSON . stringify ( opts . buildNumber ) } , 10) || 0;
186194const updater = require(path.join(SLICK_ROOT, 'scripts/byoe/updater.js')).create({ version: SLICK_VERSION, build: SLICK_BUILD, profile: PROFILE });
187195const RELEASES_URL = updater.RELEASES_URL;
188- const slackUpdater = require(path.join(SLICK_ROOT, 'scripts/byoe/slack-updater.js')).create({ version: SLICK_VERSION, profile: PROFILE });
196+ const slackUpdater = require(path.join(SLICK_ROOT, 'scripts/byoe/slack-updater.js')).create({ version: SLICK_VERSION, profile: PROFILE, slackApp: SLACK_APP });
189197
190198function slackElectronMajor() {
191199 try {
192- const plist = '/Applications/Slack.app/ Contents/Frameworks/Electron Framework.framework/Resources/Info.plist';
200+ const plist = path.join(SLACK_APP, ' Contents/Frameworks/Electron Framework.framework/Resources/Info.plist') ;
193201 const raw = require('child_process').execFileSync(
194202 '/usr/bin/plutil', ['-extract', 'CFBundleVersion', 'raw', '-o', '-', plist], { encoding: 'utf8' },
195203 );
@@ -214,7 +222,7 @@ function handlePreflight(problem) {
214222 type: 'error',
215223 title: 'Slick',
216224 message: 'Slack is not installed',
217- detail: 'Slick needs the official Slack app at /Applications/Slack.app. Install it from slack.com , then open Slick again.',
225+ detail: 'Slick needs the official Slack app at ' + SLACK_APP + '. Install it there or reinstall Slick with -- slack-app , then open Slick again.',
218226 buttons: ['Quit'],
219227 });
220228 return false;
@@ -359,6 +367,7 @@ try {
359367
360368function boot() {
361369 app.setPath('userData', PROFILE);
370+ process.env.SLICK_SLACK_APP = SLACK_APP;
362371 installPatch();
363372 seedSettings();
364373 updater.scheduleUpdateChecks();
0 commit comments