Skip to content

Commit

Permalink
Merge pull request #116 from jo/feat/update-dependencies
Browse files Browse the repository at this point in the history
feat: update dependencies
  • Loading branch information
jo committed Feb 28, 2021
2 parents 5509137 + 9c85e07 commit dea0502
Show file tree
Hide file tree
Showing 6 changed files with 24,556 additions and 32,747 deletions.
10 changes: 5 additions & 5 deletions cli.js
@@ -1,18 +1,18 @@
#!/usr/bin/env node

var minimist = require('minimist')
var push = require('./')
const minimist = require('minimist')
const push = require('./')

var options = minimist(process.argv.slice(2), {
const options = minimist(process.argv.slice(2), {
boolean: ['index', 'multipart', 'watch']
})
if (!options._.length) {
console.log('Usage: \ncouchdb-push URL [SOURCE] [OPTIONS]')
process.exit()
}

var db = options._[0]
var source = options._[1] || process.cwd()
const db = options._[0]
const source = options._[1] || process.cwd()

push(db, source, options, function (error, response) {
if (error) return console.error(error)
Expand Down
39 changes: 20 additions & 19 deletions index.js
@@ -1,14 +1,14 @@
// couchdb-push
// (c) 2014 Johannes J. Schmidt

var crypto = require('crypto')
var async = require('async')
var omit = require('lodash/omit')
var isEqual = require('lodash/isEqual')
var nanoOption = require('nano-option')
var compile = require('couchdb-compile')
var ensure = require('couchdb-ensure')
var chokidar = require('chokidar')
const crypto = require('crypto')
const async = require('async')
const omit = require('lodash/omit')
const isEqual = require('lodash/isEqual')
const nanoOption = require('nano-option')
const compile = require('couchdb-compile')
const ensure = require('couchdb-ensure')
const chokidar = require('chokidar')

module.exports = function push (db, source, options, callback) {
if (typeof options === 'function') {
Expand Down Expand Up @@ -40,10 +40,10 @@ module.exports = function push (db, source, options, callback) {
return false
}

var md5sum = crypto.createHash('md5')
var data = options.multipart ? attachment.data : Buffer.from(attachment.data, 'base64')
const md5sum = crypto.createHash('md5')
const data = options.multipart ? attachment.data : Buffer.from(attachment.data, 'base64')
md5sum.update(data)
var digest = 'md5-' + md5sum.digest('base64')
const digest = 'md5-' + md5sum.digest('base64')

return existingAttachment.digest === digest
}
Expand All @@ -53,9 +53,9 @@ module.exports = function push (db, source, options, callback) {

if (options.multipart) {
if (attachments.length) {
for (var i = 0; i < attachments.length; i++) {
var name = attachments[i].name
var identical = diffAttachment(attachments[i], existingDoc && existingDoc._attachments && existingDoc._attachments[name])
for (let i = 0; i < attachments.length; i++) {
const name = attachments[i].name
const identical = diffAttachment(attachments[i], existingDoc && existingDoc._attachments && existingDoc._attachments[name])

if (identical) {
doc._attachments = doc._attachments || {}
Expand All @@ -67,7 +67,7 @@ module.exports = function push (db, source, options, callback) {
} else {
if (doc._attachments) {
Object.keys(doc._attachments).forEach(function (name) {
var identical = diffAttachment(doc._attachments[name], existingDoc && existingDoc._attachments && existingDoc._attachments[name])
const identical = diffAttachment(doc._attachments[name], existingDoc && existingDoc._attachments && existingDoc._attachments[name])

if (identical) {
doc._attachments[name] = existingDoc._attachments[name]
Expand Down Expand Up @@ -103,8 +103,8 @@ module.exports = function push (db, source, options, callback) {
return callback(error)
}

var userDocToCompare = omit(doc, 'password')
var existingDocToCompare = omit(existingDoc, 'derived_key', 'iterations', 'password_scheme', 'salt')
const userDocToCompare = omit(doc, 'password')
const existingDocToCompare = omit(existingDoc, 'derived_key', 'iterations', 'password_scheme', 'salt')

callback(null, !isEqual(userDocToCompare, existingDocToCompare))
})
Expand Down Expand Up @@ -156,9 +156,10 @@ module.exports = function push (db, source, options, callback) {
}

if (options.watch) {
var queue = async.queue(function (task, done) {
const queue = async.queue(function (task, done) {
compileDoc(function (error, response) {
error ? console.error(error)
error
? console.error(error)
: console.log(JSON.stringify(response, null, ' '))
done(error)
})
Expand Down

0 comments on commit dea0502

Please sign in to comment.