Skip to content

Commit

Permalink
Merge pull request #57 from line-o/trigger/release
Browse files Browse the repository at this point in the history
fix: var to const
  • Loading branch information
line-o authored Jul 11, 2019
2 parents 95cd4be + 995db5d commit 7f024f7
Showing 1 changed file with 26 additions and 26 deletions.
52 changes: 26 additions & 26 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
// dependencies
var os = require('os')
var through = require('through2')
var log = require('fancy-log')
var PluginError = require('plugin-error')
var assign = require('lodash.assign')
var File = require('vinyl')
var Path = require('path')
var exist = require('@existdb/node-exist')

var defaultRPCoptions = {
const os = require('os')
const through = require('through2')
const log = require('fancy-log')
const PluginError = require('plugin-error')
const assign = require('lodash.assign')
const File = require('vinyl')
const Path = require('path')
const exist = require('@existdb/node-exist')

const defaultRPCoptions = {
host: 'localhost',
port: '8080',
path: '/exist/xmlrpc',
Expand All @@ -18,18 +18,18 @@ var defaultRPCoptions = {
}
}

var defaultUploadOptions = {
const defaultUploadOptions = {
html5AsBinary: false,
target: '',
permissions: null
}

var defaultQueryOptions = {
const defaultQueryOptions = {
printXqlResults: true,
xqlOutputExt: 'xml'
}

var isWin = os.platform() === 'win32'
const isWin = os.platform() === 'win32'

function isSaxParserError (error) {
return error && error.faultString && /SAXParseException/.test(error.faultString)
Expand All @@ -40,14 +40,14 @@ function normalizePath (path) {
}

function createCollection (client, collection) {
var normalizedCollectionPath = normalizePath(collection)
const normalizedCollectionPath = normalizePath(collection)
log('Creating collection "' + normalizedCollectionPath + '"...')
return client.collections.create(normalizedCollectionPath)
}

module.exports.createClient = function createClient (options) {
// TODO sanity checks
var client = exist.connect(assign({}, defaultRPCoptions, options))
const client = exist.connect(assign({}, defaultRPCoptions, options))
return {
dest: sendFilesWith(client),
query: queryWith(client),
Expand All @@ -65,9 +65,9 @@ module.exports.getMimeType = function (path) {

function sendFilesWith (client) {
return function send (options) {
var conf = assign({}, defaultUploadOptions, options)
const conf = assign({}, defaultUploadOptions, options)

var storeFile = function (vf, enc, callback) {
const storeFile = function (vf, enc, callback) {
if (vf.isStream()) {
return this.emit('error', new PluginError('gulp-exist', 'Streaming not supported'))
}
Expand All @@ -84,16 +84,16 @@ function sendFilesWith (client) {
}

// rewrap to newer version of vinyl file object
var file = new File({
const file = new File({
base: vf.base,
path: vf.path,
contents: vf.contents
})

var remotePath = normalizePath(conf.target + '/' + file.relative)
const remotePath = normalizePath(conf.target + '/' + file.relative)

var folder = file.relative.substring(0, file.relative.length - file.basename.length)
var collection = Path.normalize(conf.target) + '/' + folder
const folder = file.relative.substring(0, file.relative.length - file.basename.length)
const collection = Path.normalize(conf.target) + '/' + folder

// create target collection if neccessary
return client.collections.describe(collection)
Expand Down Expand Up @@ -150,7 +150,7 @@ function sendFilesWith (client) {

function queryWith (client) {
return function query (options) {
var conf = assign({}, defaultQueryOptions, options)
const conf = assign({}, defaultQueryOptions, options)

function executeQuery (file, enc, callback) {
if (file.isStream()) {
Expand All @@ -166,7 +166,7 @@ function queryWith (client) {

client.queries.readAll(file.contents, {})
.then(function (result) {
var resultBuffer = Buffer.concat(result.pages)
const resultBuffer = Buffer.concat(result.pages)
if (conf.printXqlResults) {
log(resultBuffer.toString())
}
Expand All @@ -187,11 +187,11 @@ function queryWith (client) {

function checkForNewerWith (client) {
return function newer (options) {
var conf = assign({}, defaultUploadOptions, options)
const conf = assign({}, defaultUploadOptions, options)

function checkFile (file, enc, callback) {
if (file.isDirectory()) {
var collection = normalizePath(conf.target + '/' + file.relative)
const collection = normalizePath(conf.target + '/' + file.relative)
client.collections.describe(collection)
.then(function () {
callback(null)
Expand All @@ -204,7 +204,7 @@ function checkForNewerWith (client) {

client.resources.describe(normalizePath(conf.target + '/' + file.relative))
.then(function (resourceInfo) {
var newer = !resourceInfo.hasOwnProperty('modified') || (Date.parse(file.stat.mtime) > Date.parse(resourceInfo.modified))
const newer = !resourceInfo.hasOwnProperty('modified') || (Date.parse(file.stat.mtime) > Date.parse(resourceInfo.modified))
callback(null, newer ? file : null)
})
.catch(function (e) {
Expand Down

0 comments on commit 7f024f7

Please sign in to comment.