diff --git a/bin/watch.js b/bin/watch.js index f713e46..3ebaecf 100755 --- a/bin/watch.js +++ b/bin/watch.js @@ -17,6 +17,7 @@ const nodeFetch = require('node-fetch'); const keytar = require('keytar'); const url = require('url'); const inquirer = require('inquirer'); +const https = require('https'); require('yargs') .command('watch [folder]', 'watch the folder', (yargs) => { @@ -34,6 +35,12 @@ require('yargs') describe: 'Webdav server url', type: 'string', }) + .option('ssl', { + alias: 's', + describe: 'Suppress ssl issues', + type: 'boolean', + default: false + }) .option('username', { alias: 'u', describe: 'Webdav user to login', @@ -85,7 +92,9 @@ require('yargs') logger.silly(`About to upload file ${chalk.cyan(remoteFilepath)} on remote server ${chalk.cyan(argv.remote)}`); - fetch(remoteFilepath, { body: fileContents }) + const httpsAgent = new https.Agent({ rejectUnauthorized: false }); + const opts = argv.ssl ? { body: fileContents, agent: httpsAgent } : { body: fileContents }; + fetch(remoteFilepath, opts) .then(() => { logger.info(`Successfully uploaded file ${chalk.green(remoteFilepath)}`); notifier.notify({ diff --git a/package.json b/package.json index abb6036..9a7e28b 100644 --- a/package.json +++ b/package.json @@ -32,6 +32,7 @@ "chalk": "^2.3.1", "node-fetch": "^2.0.0", "keytar": "^4.1.0", - "inquirer": "^5.1.0" + "inquirer": "^5.1.0", + "https": "^1.0.0" } }