diff --git a/API.md b/API.md index d069c6a..b9938ca 100644 --- a/API.md +++ b/API.md @@ -115,7 +115,9 @@ The url to point the application at. #### [dest] -Specifies the destination directory to build the app to, defaults to the current working directory. +Specifies the destination directory to build the app to, defaults to `NATIVEFIER_APPS_DIR` environment variable, or the current working directory if it is not set. + +**Tip:** Add `export NATIVEFIER_APPS_DIR=~/Applications/` to your `~/.bashrc` , `~/.zshrc`, or similar file to set the default app destination if none is passed. This lets you run `nativefier example.com` and have it automatically save it to your Applications folder on macOS. #### Help diff --git a/src/cli.ts b/src/cli.ts index 7c34fe5..c5b732f 100755 --- a/src/cli.ts +++ b/src/cli.ts @@ -45,7 +45,8 @@ export function initArgs(argv: string[]): yargs.Argv { type: 'string', }) .positional('outputDirectory', { - defaultDescription: 'current directory', + defaultDescription: + 'NATIVEFIER_APPS_DIR environment variable, or current directory if not set', description: 'the directory to generate the app in', normalize: true, type: 'string', @@ -667,6 +668,10 @@ if (require.main === module) { checkInternet(); + if (!options.out && process.env.NATIVEFIER_APPS_DIR) { + options.out = process.env.NATIVEFIER_APPS_DIR; + } + buildNativefierApp(options).catch((error) => { log.error('Error during build. Run with --verbose for details.', error); });