diff --git a/app/src/main.js b/app/src/main.js index 29b1e74..fb4dd82 100644 --- a/app/src/main.js +++ b/app/src/main.js @@ -12,11 +12,12 @@ import inferFlash from './helpers/inferFlash'; const { isOSX } = helpers; -electronDownload(); - const APP_ARGS_FILE_PATH = path.join(__dirname, '..', 'nativefier.json'); const appArgs = JSON.parse(fs.readFileSync(APP_ARGS_FILE_PATH, 'utf8')); +const fileDownloadOptions = Object.assign({}, appArgs.fileDownloadOptions); +electronDownload(fileDownloadOptions); + if (appArgs.processEnvs) { Object.keys(appArgs.processEnvs).forEach((key) => { /* eslint-env node */ diff --git a/docs/api.md b/docs/api.md index a73e9a6..5ccc0d4 100644 --- a/docs/api.md +++ b/docs/api.md @@ -460,6 +460,20 @@ Example: nativefier --processEnvs '{"GOOGLE_API_KEY": ""}' ``` +#### [file-download-options] + +``` +--file-download-options +``` + +a JSON string of key/value pairs to be set as file download options. See [electron-dl](https://github.com/sindresorhus/electron-dl) for available options. + +Example: + +```bash +nativefier --file-download-options '{"saveAs": true}' +``` + ## Programmatic API You can use the Nativefier programmatic API as well. @@ -498,6 +512,9 @@ var options = { honest: false, zoom: 1.0, singleInstance: false, + fileDownloadOptions: { + saveAs: true // always show "Save As" dialog + }, processEnvs: { "GOOGLE_API_KEY": "" } diff --git a/src/build/buildApp.js b/src/build/buildApp.js index 436bb1b..22ae2a0 100644 --- a/src/build/buildApp.js +++ b/src/build/buildApp.js @@ -48,6 +48,7 @@ function selectAppArgs(options) { win32metadata: options.win32metadata, versionString: options.versionString, processEnvs: options.processEnvs, + fileDownloadOptions: options.fileDownloadOptions, tray: options.tray, basicAuthUsername: options.basicAuthUsername, basicAuthPassword: options.basicAuthPassword, diff --git a/src/cli.js b/src/cli.js index e219490..743e07f 100755 --- a/src/cli.js +++ b/src/cli.js @@ -85,6 +85,7 @@ if (require.main === module) { .option('--crash-reporter ', 'remote server URL to send crash reports') .option('--single-instance', 'allow only a single instance of the application') .option('--processEnvs ', 'a JSON string of key/value pairs to be set as environment variables before any browser windows are opened.', getProcessEnvs) + .option('--file-download-options ', 'a JSON string of key/value pairs to be set as file download options. See https://github.com/sindresorhus/electron-dl for available options.', parseJson) .option('--tray', 'allow app to stay in system tray') .option('--basic-auth-username ', 'basic http(s) auth username') .option('--basic-auth-password ', 'basic http(s) auth password') diff --git a/src/options/optionsMain.js b/src/options/optionsMain.js index 9d25f0e..9144aad 100644 --- a/src/options/optionsMain.js +++ b/src/options/optionsMain.js @@ -66,6 +66,7 @@ export default function (inpOptions) { FileDescription: inpOptions.name, }, processEnvs: inpOptions.processEnvs, + fileDownloadOptions: inpOptions.fileDownloadOptions, tray: inpOptions.tray || false, basicAuthUsername: inpOptions.basicAuthUsername || null, basicAuthPassword: inpOptions.basicAuthPassword || null,