Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion bin/watch.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand All @@ -34,6 +35,12 @@ require('yargs')
describe: 'Webdav server url',
type: 'string',
})
.option('ssl', {
alias: 's',
describe: 'Suppress ssl issues',
type: 'boolean',
default: false
})
Comment on lines +38 to +43
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's name this option strict-ssl-verification and it's default should be true

.option('username', {
alias: 'u',
describe: 'Webdav user to login',
Expand Down Expand Up @@ -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 };
Comment on lines +95 to +96
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const httpsAgent = new https.Agent({ rejectUnauthorized: false });
const opts = argv.ssl ? { body: fileContents, agent: httpsAgent } : { body: fileContents };
const agent = new https.Agent({ rejectUnauthorized: !argv.strictSslVerification });
const opts = Object.assign({body: fileContents}, argv.strictSslVerification ? {} : { agent });

fetch(remoteFilepath, opts)
.then(() => {
logger.info(`Successfully uploaded file ${chalk.green(remoteFilepath)}`);
notifier.notify({
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Comment on lines +35 to +36
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since we are in nodejs environment, we don't need this dependency

Suggested change
"inquirer": "^5.1.0",
"https": "^1.0.0"
"inquirer": "^5.1.0"

}
}