-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: adds headless mode and command line args (#279)
* feat: adds headless mode and command line args
- Loading branch information
Showing
8 changed files
with
65 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
export * from './lib/postybirb-env-config'; | ||
export * from './lib/startup-options-electron'; | ||
export * from './lib/utils-electron'; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { app } from 'electron'; | ||
import minimist from 'minimist'; | ||
import { getStartupOptions } from './startup-options-electron'; | ||
|
||
export type AppEnvConfig = { | ||
port: string; | ||
headless: boolean; | ||
}; | ||
|
||
const config: AppEnvConfig = { | ||
port: | ||
process.env.POSTYBIRB_PORT || getStartupOptions().port.toString() || '9487', | ||
headless: process.env.POSTYBIRB_HEADLESS === 'true' || false, | ||
}; | ||
|
||
const args = minimist(process.argv.slice(process.defaultApp ? 2 : 1)); | ||
if (args.port) { | ||
config.port = args.port; | ||
} | ||
if (args.headless) { | ||
config.headless = args.headless; | ||
} | ||
|
||
const portNumber = parseInt(config.port, 10); | ||
if (!(portNumber >= 1024 && portNumber <= 65535)) { | ||
// eslint-disable-next-line no-console | ||
console.error( | ||
'Invalid port number. Please provide a port number between 1024 and 65535.' | ||
); | ||
app.quit(); | ||
} | ||
|
||
export { config as PostyBirbEnvConfig }; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters