1
1
// dependencies
2
- var os = require ( 'os' )
3
- var through = require ( 'through2' )
4
- var log = require ( 'fancy-log' )
5
- var PluginError = require ( 'plugin-error' )
6
- var assign = require ( 'lodash.assign' )
7
- var File = require ( 'vinyl' )
8
- var Path = require ( 'path' )
9
- var exist = require ( '@existdb/node-exist' )
10
-
11
- var defaultRPCoptions = {
2
+ const os = require ( 'os' )
3
+ const through = require ( 'through2' )
4
+ const log = require ( 'fancy-log' )
5
+ const PluginError = require ( 'plugin-error' )
6
+ const assign = require ( 'lodash.assign' )
7
+ const File = require ( 'vinyl' )
8
+ const Path = require ( 'path' )
9
+ const exist = require ( '@existdb/node-exist' )
10
+
11
+ const defaultRPCoptions = {
12
12
host : 'localhost' ,
13
13
port : '8080' ,
14
14
path : '/exist/xmlrpc' ,
@@ -18,18 +18,18 @@ var defaultRPCoptions = {
18
18
}
19
19
}
20
20
21
- var defaultUploadOptions = {
21
+ const defaultUploadOptions = {
22
22
html5AsBinary : false ,
23
23
target : '' ,
24
24
permissions : null
25
25
}
26
26
27
- var defaultQueryOptions = {
27
+ const defaultQueryOptions = {
28
28
printXqlResults : true ,
29
29
xqlOutputExt : 'xml'
30
30
}
31
31
32
- var isWin = os . platform ( ) === 'win32'
32
+ const isWin = os . platform ( ) === 'win32'
33
33
34
34
function isSaxParserError ( error ) {
35
35
return error && error . faultString && / S A X P a r s e E x c e p t i o n / . test ( error . faultString )
@@ -40,14 +40,14 @@ function normalizePath (path) {
40
40
}
41
41
42
42
function createCollection ( client , collection ) {
43
- var normalizedCollectionPath = normalizePath ( collection )
43
+ const normalizedCollectionPath = normalizePath ( collection )
44
44
log ( 'Creating collection "' + normalizedCollectionPath + '"...' )
45
45
return client . collections . create ( normalizedCollectionPath )
46
46
}
47
47
48
48
module . exports . createClient = function createClient ( options ) {
49
49
// TODO sanity checks
50
- var client = exist . connect ( assign ( { } , defaultRPCoptions , options ) )
50
+ const client = exist . connect ( assign ( { } , defaultRPCoptions , options ) )
51
51
return {
52
52
dest : sendFilesWith ( client ) ,
53
53
query : queryWith ( client ) ,
@@ -65,9 +65,9 @@ module.exports.getMimeType = function (path) {
65
65
66
66
function sendFilesWith ( client ) {
67
67
return function send ( options ) {
68
- var conf = assign ( { } , defaultUploadOptions , options )
68
+ const conf = assign ( { } , defaultUploadOptions , options )
69
69
70
- var storeFile = function ( vf , enc , callback ) {
70
+ const storeFile = function ( vf , enc , callback ) {
71
71
if ( vf . isStream ( ) ) {
72
72
return this . emit ( 'error' , new PluginError ( 'gulp-exist' , 'Streaming not supported' ) )
73
73
}
@@ -84,16 +84,16 @@ function sendFilesWith (client) {
84
84
}
85
85
86
86
// rewrap to newer version of vinyl file object
87
- var file = new File ( {
87
+ const file = new File ( {
88
88
base : vf . base ,
89
89
path : vf . path ,
90
90
contents : vf . contents
91
91
} )
92
92
93
- var remotePath = normalizePath ( conf . target + '/' + file . relative )
93
+ const remotePath = normalizePath ( conf . target + '/' + file . relative )
94
94
95
- var folder = file . relative . substring ( 0 , file . relative . length - file . basename . length )
96
- var collection = Path . normalize ( conf . target ) + '/' + folder
95
+ const folder = file . relative . substring ( 0 , file . relative . length - file . basename . length )
96
+ const collection = Path . normalize ( conf . target ) + '/' + folder
97
97
98
98
// create target collection if neccessary
99
99
return client . collections . describe ( collection )
@@ -150,7 +150,7 @@ function sendFilesWith (client) {
150
150
151
151
function queryWith ( client ) {
152
152
return function query ( options ) {
153
- var conf = assign ( { } , defaultQueryOptions , options )
153
+ const conf = assign ( { } , defaultQueryOptions , options )
154
154
155
155
function executeQuery ( file , enc , callback ) {
156
156
if ( file . isStream ( ) ) {
@@ -166,7 +166,7 @@ function queryWith (client) {
166
166
167
167
client . queries . readAll ( file . contents , { } )
168
168
. then ( function ( result ) {
169
- var resultBuffer = Buffer . concat ( result . pages )
169
+ const resultBuffer = Buffer . concat ( result . pages )
170
170
if ( conf . printXqlResults ) {
171
171
log ( resultBuffer . toString ( ) )
172
172
}
@@ -187,11 +187,11 @@ function queryWith (client) {
187
187
188
188
function checkForNewerWith ( client ) {
189
189
return function newer ( options ) {
190
- var conf = assign ( { } , defaultUploadOptions , options )
190
+ const conf = assign ( { } , defaultUploadOptions , options )
191
191
192
192
function checkFile ( file , enc , callback ) {
193
193
if ( file . isDirectory ( ) ) {
194
- var collection = normalizePath ( conf . target + '/' + file . relative )
194
+ const collection = normalizePath ( conf . target + '/' + file . relative )
195
195
client . collections . describe ( collection )
196
196
. then ( function ( ) {
197
197
callback ( null )
@@ -204,7 +204,7 @@ function checkForNewerWith (client) {
204
204
205
205
client . resources . describe ( normalizePath ( conf . target + '/' + file . relative ) )
206
206
. then ( function ( resourceInfo ) {
207
- var newer = ! resourceInfo . hasOwnProperty ( 'modified' ) || ( Date . parse ( file . stat . mtime ) > Date . parse ( resourceInfo . modified ) )
207
+ const newer = ! resourceInfo . hasOwnProperty ( 'modified' ) || ( Date . parse ( file . stat . mtime ) > Date . parse ( resourceInfo . modified ) )
208
208
callback ( null , newer ? file : null )
209
209
} )
210
210
. catch ( function ( e ) {
0 commit comments