forked from boneskull/rsync
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.js
995 lines (886 loc) · 22.9 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
'use strict';
const spawn = require('cross-spawn');
const path = require('path');
const which = require('which').sync;
const unixify = require('unixify');
/**
* Rsync is a wrapper class to configure and execute an `rsync` command
* in a fluent and convenient way.
*
* A new command can be set up by creating a new `Rsync` instance of
* obtaining one through the `build` method.
*
* @example
* // using the constructor
* var rsync = new Rsync()
* .source('/path/to/source')
* .destination('myserver:destination/');
*
* // using the build method with options
* var rsync = Rsync.build({
* source: '/path/to/source',
* destination: 'myserver:destination/'
* });
*
* Executing the command can be done using the `execute` method. The command
* is executed as a child process and three callbacks can be registered. See
* the `execute` method for more details.
*
* @example
* rsync.execute((error, code, cmd) => {
* // function called when the child process is finished
* }, stdoutChunk => {
* // function called when a chunk of text is received on stdout
* }, stderrChunk => {
* // function called when a chunk of text is received on stderr
* });
*
* @author Mattijs Hoitink <[email protected]>
* @copyright Copyright (c) 2013, Mattijs Hoitink
* @license The MIT License
*
* @constructor
* @param {Object} config Configuration settings for the Rsync wrapper.
*/
class Rsync {
constructor ({ executable = which('rsync'), stderr = process.stderr, stdout = process.stdout, stdin = process.stdin } = {}) {
// executable
this._executable = executable;
// source(s) and destination
this._sources = [];
this._destination = '';
// ordered list of file patterns to include/exclude
this._patterns = [];
// options
this._options = new Proxy(Object.create(null), {
get (target, prop) {
prop = stripLeadingDashes(prop);
return target[prop];
},
set (target, prop, value) {
prop = stripLeadingDashes(prop);
target[prop] = value;
return true;
},
deleteProperty (target, prop) {
prop = stripLeadingDashes(prop);
delete target[prop];
return true;
},
has (target, prop) {
prop = stripLeadingDashes(prop);
return prop in target;
}
});
// output callbacks
this._outputHandlers = {
stdout: noop,
stderr: noop
};
this._cwd = process.cwd();
// Allow child_process.spawn env overriding
this._env = process.env;
this._stderr = stderr;
this._stdout = stdout;
this._stdin = stdin;
}
/**
* Set an option.
* @param {string} option - Option name
* @param {*} [value] - Whatever value
* @return {Rsync}
*/
set (option, value) {
if (Array.isArray(option)) {
option.forEach(optionArr => {
this._options[optionArr[0]] = optionArr[1];
});
} else {
this._options[option] = value;
}
return this;
}
/**
* Unset an option.
* @param {string} option - Option name
* @return {Rsync}
*/
unset (option) {
if (option) {
delete this._options[option];
}
return this;
}
/**
* Sets an Array of flags or a string of flags to `true`
* @param {string|...string|string[]|...string[]} flags - Flags to set to
* `true`
* @returns {Rsync}
* @example
* rsync.setFlags('avz')
* // equivalent to:
* rsync.setFlags(['a', 'v', 'z'])
* // and:
* rsync.setFlags('a', 'v', 'z')
*/
setFlags (...flags) {
parseFlags(...flags).forEach(flag => {
this.set(flag);
});
return this;
}
/**
* Sets an Array of flags or a string of flags to `false`
* @param {string|...string|string[]|...string[]} flags - Flags to set to
* `false`
* @returns {Rsync}
* @example
* rsync.unsetFlags('avz')
* // equivalent to:
* rsync.unsetFlags(['a', 'v', 'z'])
* // and:
* rsync.unsetFlags('a', 'v', 'z')
*/
unsetFlags (...flags) {
parseFlags(...flags).forEach(flag => {
this.unset(flag);
});
return this;
}
/**
* Check if an option is set.
* @param {string} option
* @return {boolean}
*/
isSet (option) {
return option in this._options;
}
/**
* Get an option by name.
* @param {string} name - Option name
* @return {*}
*/
option (name) {
return this._options[name];
}
/**
* Register a list of file patterns to include/exclude in the transfer.
* Patterns can be registered as an array of Strings or Objects.
*
* When registering a pattern as a string it must be prefixed with a `+` or
* `-` sign to signal include or exclude for the pattern. The sign will be
* stripped of and the pattern will be added to the ordered pattern list.
*
* When registering the pattern as an Object it must contain the `action` and
* `pattern` keys where `action` contains the `+` or `-` sign and the
* `pattern` key contains the file pattern, without the `+` or `-` sign.
*
* @example
* // on an existing rsync object
* rsync.patterns(['-docs', { action: '+', pattern: '/subdir/*.py' }]);
*
* // using Rsync.build for a new rsync object
* rsync = Rsync.build({
* ...
* patterns: [ '-docs', { action: '+', pattern: '/subdir/*.py' }]
* ...
* })
*
* @param {Array} patterns
* @return {Rsync}
*/
patterns (...patterns) {
patterns.forEach(pattern => {
if (Array.isArray(pattern)) {
return this.patterns(...pattern);
}
let action = '?';
if (typeof pattern === 'string') {
action = pattern.charAt(0);
pattern = pattern.substring(1);
} else if (typeof pattern === 'object' && 'action' in pattern &&
'pattern' in pattern) {
action = pattern.action;
pattern = pattern.pattern;
}
// Check if the pattern is an include or exclude
if (action === '-') {
this.exclude(pattern);
} else {
this.include(pattern);
}
});
return this;
}
/**
* Exclude a file pattern from transfer. The pattern will be appended to the
* ordered list of patterns for the rsync command.
*
* @param {...string|...string[]} patterns
* @return {Rsync}
*/
exclude (...patterns) {
patterns.forEach(pattern => {
if (Array.isArray(pattern)) {
return this.exclude(...pattern);
}
this._patterns.push({
action: '-',
pattern
});
});
return this;
}
/**
* Include a file pattern for transfer. The pattern will be appended to the
* ordered list of patterns for the rsync command.
*
* @param {string|Array} patterns
* @return {Rsync}
*/
include (...patterns) {
patterns.forEach(pattern => {
if (Array.isArray(pattern)) {
return this.include(...pattern);
}
this._patterns.push({
action: '+',
pattern
});
});
return this;
}
/**
* Get the command that is going to be executed.
* @return {string}
*/
command () {
return `${this.executable()} ${this.args().join(' ')}`;
}
/**
* Get the arguments for the rsync command.
* @return {Array}
*/
args () {
// Gathered arguments
let args = [];
// Add options. Short options (one letter) without values are gathered
// together. Long options have a value but can also be a single letter.
let short = [];
let long = [];
// Split long and short options
Object.keys(this._options).forEach(key => {
const value = this._options[key];
if (key.length === 1 && typeof value === 'undefined') {
short = short.concat(key);
} else {
long =
Array.isArray(value)
? long.concat(value.map(
val => buildOption(key, val, escapeShellArg)))
: long.concat(
buildOption(key, value, escapeShellArg));
}
});
// Add combined short options if any are present
if (short.length) {
args = args.concat(`-${short.join('')}`);
}
// Add long options if any are present
if (long.length) {
args = args.concat(long);
}
// Add includes/excludes in order
args =
args.concat(this._patterns.map(({ action, pattern }) => buildOption(action ===
'-'
? 'exclude'
: 'include', pattern)));
// Add sources
if (this.source().length) {
args = args.concat(this.source().map(source => unixify(source, false)));
}
// Add destination
if (this.destination()) {
args = args.concat(unixify(this.destination(), false));
}
return args;
}
/**
* Get and set rsync process cwd directory.
*
* @param {string} [cwd] Directory path relative to current process directory.
* @return {string} Return current _cwd.
*/
cwd (cwd) {
if (cwd) {
this._cwd = path.posix.resolve(cwd);
}
return this._cwd;
}
/**
* Get and set rsync process environment variables
*
* @param {string} [env] Environment variables
* @return {string} Return current _env.
*/
env (env) {
if (env) {
this._env = env;
}
return this._env;
}
/**
* Register an output handlers for the commands stdout and stderr streams.
* These functions will be called once data is streamed on one of the output
* buffers when the command is executed using `execute`.
*
* Only one callback function can be registered for each output stream.
* Previously registered callbacks will be overridden.
*
* @param {Function} stdout - Callback Function for stdout `data` event
* @param {Function} stderr - Callback Function for stderr `data` event
* @return {Rsync}
*/
output (stdout, stderr) {
// Check for single argument so the method can be used with Rsync.build
if (arguments.length === 1 && Array.isArray(stdout)) {
[stderr, stdout] = stdout;
}
if (typeof stdout === 'function') {
this._outputHandlers.stdout = stdout;
}
if (typeof stderr === 'function') {
this._outputHandlers.stderr = stderr;
}
return this;
}
/**
* Execute the rsync command.
*
* The callback function is called with an Error object (or null when there
* was none), the exit code from the executed command and the executed
* command as a string.
*
* When stdoutHandler and stderrHandler functions are provided they will be
* used to stream data from stdout and stderr directly without buffering.
*
* @param {Object} [opts] Options
* @param {Function} [opts.stdoutHandler] Called on each chunk received from
* stdout
* @param {Function} [opts.stderrHandler] - Called on each chunk received from
* stdout
* @param {Function} [callback] - Node-style callback. If present, return the
* `ChildProcess` object, otherwise return a `Promise`.
* @returns {Promise<void>|ChildProcess}
*/
execute (opts = {}) {
// Register output handlers
this.output(
opts.stdoutHandler || this._outputHandlers.stdout,
opts.stderrHandler || this._outputHandlers.stderr
);
const promise = new Promise((resolve, reject) => {
// use shell: true because spawn screws up quotes without it
const cmdProc = spawn(this.executable(), this.args(), {
cwd: this._cwd,
env: this._env,
shell: true
});
cmdProc.stdout.on('data', this._outputHandlers.stdout);
cmdProc.stderr.on('data', this._outputHandlers.stderr);
cmdProc.on('error', reject);
cmdProc.on('close', code => {
if (code) {
const errorObj = new Error(`rsync exited with code ${code}`);
errorObj.code = code;
return reject(errorObj);
}
resolve(code);
});
}).catch(err => {
return Promise.reject(err);
});
return promise;
}
/**
* @deprecated
*/
// flags () {
// throw new Error('flags() is deprecated; use setFlags() or unsetFlags() instead');
// }
flags (flags) {
this.setFlags(flags);
}
}
/**
* Build a new Rsync command from an options Object.
* @param {Object} options
* @return {Rsync}
*/
Rsync.build = options => {
const command = new Rsync();
// Process all options
Object.keys(options).forEach(key => {
const value = options[key];
if (typeof command[key] === 'function') {
command[key](value);
}
});
return command;
};
/**
* string representation of the Rsync command. This is the command that is
* going to be executed when calling Rsync::execute.
* @return {string}
*/
Rsync.prototype.toString = Rsync.prototype.command;
/* **** */
/**
* Create a chainable function on the Rsync prototype for getting and setting an
* internal value.
* @param {string} name
* @param {string} [internal=false]
*/
const createValueAccessor = (name, internal = false) => {
const container = internal || `_${name}`;
Rsync.prototype[name] = function (value) {
if (!arguments.length) {
return this[container];
}
this[container] = value;
return this;
};
};
/**
* @param {string} name
* @param {string} internal
*/
const createListAccessor = (name, internal) => {
const container = internal || `_${name}`;
Rsync.prototype[name] = function (value) {
if (!arguments.length) {
return this[container];
}
if (Array.isArray(value)) {
value.forEach(this[name], this);
} else if (typeof value !== 'string') {
throw new Error(`Value for Rsync::${name} must be a String`);
} else if (this[container].indexOf(value) < 0) {
this[container].push(value);
}
return this;
};
};
/**
* Create a shorthand method on the Rsync prototype for setting and unsetting a
* simple option.
* @param {string} option
* @param {string} [name]
*/
const exposeShortOption = (option, name) => {
name = name || option;
Rsync.prototype[name] = function (set = true) {
return this[set ? 'set' : 'unset'](option);
};
};
/**
* Create a function for an option that can be set multiple time. The option
* will accumulate all values.
*
* @param {string} option
* @param {[string]} name
*/
const exposeMultiOption = (option, name) => {
name = name || option;
Rsync.prototype[name] = function (value) {
// When not arguments are passed in assume the options
// current value is requested
if (!arguments.length) {
return this.option(option);
}
if (!value) {
// Unset the option on falsy
this.unset(option);
} else if (Array.isArray(value)) {
// Call this method for each array value
value.forEach(this[name], this);
} else {
// Add the value
const current = this.option(option);
if (!current) {
value = [value];
} else if (!Array.isArray(current)) {
value = [current, value];
} else {
value = current.concat(value);
}
this.set(option, value);
}
return this;
};
};
/**
* Expose an rsync long option on the Rsync prototype.
* @param {string} option The option to expose
* @param {string} name An optional alternative name for the option.
*/
const exposeLongOption = (option, name) => {
name = name || option;
Rsync.prototype[name] = function (value) {
// When not arguments are passed in assume the options
// current value is requested
if (!arguments.length) {
return this.option(option);
}
return this[value ? 'set' : 'unset'](option, value);
};
};
/**
* Build an option for use in a shell command.
*
* @param {string} name
* @param {string} value
* @param {Function|boolean} escapeArg
* @return {string}
*/
const buildOption = (name, value, escapeArg) => {
if (typeof escapeArg === 'boolean') {
escapeArg = escapeArg ? null : noop;
}
if (typeof escapeArg !== 'function') {
escapeArg = escapeShellArg;
}
// Detect single option key
const single = name.length === 1;
// Decide on prefix and value glue
const prefix = single ? '-' : '--';
const glue = single ? ' ' : '=';
// Build the option
let option = prefix + name;
if (name && value) {
value = escapeArg(String(value));
option += glue + value;
}
// if (arguments.length > 1 && value) {
// value = escapeArg(String(value));
// option += glue + value;
// }
return option;
};
/**
* Escape an argument for use in a shell command when necessary.
* @param {string} arg
* @return {string}
*/
const escapeShellArg = arg => {
if (!/(["'`\\$ ])/.test(arg)) {
return arg;
}
return `"${arg.replace(/(["'`\\$])/g, '\\$1')}"`;
};
/**
* Strip the leading dashes from a value.
* @param {string} value
* @return {string}
*/
const stripLeadingDashes = value => {
if (typeof value === 'string') {
value = value.replace(/^[-]*/, '');
}
return value;
};
const noop = _ => {
};
const parseFlags = (...flags) => flags.reduce((acc, flag) => acc.concat(typeof (
flag
) === 'string'
? flag.split('')
: parseFlags(...flag)), []);
/**
* Set a custom writable stream for stdout
* @function
* @name stdout
* @memberOf Rsync.prototype
* @param {stream.Writable|stream.Duplex} stream - New stdout
* @return {Rsync|stream.Writable|stream.Duplex}
*/
createValueAccessor('stdout');
/**
* Set a custom writable stream for stderr
* @function
* @name stderr
* @memberOf Rsync.prototype
* @param {stream.Writable|stream.Duplex} stream - New stderr
* @return {Rsync|stream.Writable|stream.Duplex}
*/
createValueAccessor('stderr');
/**
* Set a custom readable stream for stdout
* @function
* @name stdin
* @memberOf Rsync.prototype
* @param {stream.Readable|stream.Duplex} stream - New stdin
* @return {Rsync|stream.Readable|stream.Duplex}
*/
createValueAccessor('stdin');
/**
* Get or set the executable to use for the rsync process.
*
* When setting the executable path the Rsync instance is returned for
* the fluent interface. Otherwise the configured executable path
* is returned.
*
* @function
* @name executable
* @memberOf Rsync.prototype
* @param {string} executable path to the executable (optional)
* @return {Rsync|string}
*/
createValueAccessor('executable');
/**
* Get or set the destination for the transfer.
*
* When setting the destination the Rsync instance is returned for
* the fluent interface. Otherwise the configured destination path
* is returned.
*
* @function
* @name destination
* @memberOf Rsync.prototype
* @param {string} destination the destination (optional)
* @return {Rsync|string}
*/
createValueAccessor('destination');
/**
* Add one or more sources for the command or get the list of configured
* sources.
*
* The sources are appended to the list of known sources if they were not
* included yet and the Rsync instance is returned for the fluent
* interface. Otherwise the configured list of source is returned.
*
* @function
* @name source
* @memberOf Rsync.prototype
* @param {string|Array} sources the source or list of sources to configure
* (optional)
* @return {Rsync|Array}
*/
createListAccessor('source', '_sources');
/**
* Set the shell to use when logging in on a remote server.
*
* This is the same as setting the `rsh` option.
*
* @function
* @name shell
* @memberOf Rsync.prototype
* @param {string} shell the shell option to use
* @return {Rsync}
*/
exposeLongOption('rsh', 'shell');
/**
* Add a chmod instruction to the command.
*
* @function
* @name chmod
* @memberOf Rsync.prototype
* @param {string|Array}
* @return {Rsync|Array}
*/
exposeMultiOption('chmod', 'chmod');
/**
* Set the delete flag.
*
* This is the same as setting the `--delete` commandline flag.
*
* @function
* @name delete
* @memberOf Rsync.prototype
* @return {Rsync}
*/
exposeShortOption('delete');
/**
* Set the progress flag.
*
* This is the same as setting the `--progress` commandline flag.
*
* @function
* @name progress
* @memberOf Rsync.prototype
* @return {Rsync}
*/
exposeShortOption('progress');
/**
* Set the archive flag.
*
* @function
* @name archive
* @memberOf Rsync.prototype
* @return {Rsync}
*/
exposeShortOption('a', 'archive');
/**
* Set the compress flag.
*
* @function
* @name compress
* @memberOf Rsync.prototype
* @return {Rsync}
*/
exposeShortOption('z', 'compress');
/**
* Set the recursive flag.
*
* @function
* @name recursive
* @memberOf Rsync.prototype
* @return {Rsync}
*/
exposeShortOption('r', 'recursive');
/**
* Set the update flag.
*
* @function
* @name update
* @memberOf Rsync.prototype
* @return {Rsync}
*/
exposeShortOption('u', 'update');
/**
* Set the quiet flag.
*
* @function
* @name quiet
* @memberOf Rsync.prototype
* @return {Rsync}
*/
exposeShortOption('q', 'quiet');
/**
* Set the dirs flag.
*
* @function
* @name dirs
* @memberOf Rsync.prototype
* @return {Rsync}
*/
exposeShortOption('d', 'dirs');
/**
* Set the links flag.
*
* @function
* @name links
* @memberOf Rsync.prototype
* @return {Rsync}
*/
exposeShortOption('l', 'links');
/**
* Set the dry flag.
*
* @function
* @name dry
* @memberOf Rsync.prototype
* @return {Rsync}
*/
exposeShortOption('n', 'dry');
/**
* Set the hard links flag preserving hard links for the files transmitted.
*
* @function
* @name hardLinks
* @memberOf Rsync.prototype
* @return {Rsync}
*/
exposeShortOption('H', 'hardLinks');
/**
* Set the perms flag.
*
* @function
* @name perms
* @memberOf Rsync.prototype
* @return {Rsync}
*/
exposeShortOption('p', 'perms');
/**
* Set the executability flag to preserve executability for the files
* transmitted.
*
* @function
* @name executability
* @memberOf Rsync.prototype
* @return {Rsync}
*/
exposeShortOption('E', 'executability');
/**
* Set the group flag to preserve the group permissions of the files
* transmitted.
*
* @function
* @name group
* @memberOf Rsync.prototype
* @return {Rsync}
*/
exposeShortOption('g', 'group');
/**
* Set the owner flag to preserve the owner of the files transmitted.
*
* @function
* @name owner
* @memberOf Rsync.prototype
* @return {Rsync}
*/
exposeShortOption('o', 'owner');
/**
* Set the acls flag to preserve the ACLs for the files transmitted.
*
* @function
* @name acls
* @memberOf Rsync.prototype
* @return {Rsync}
*/
exposeShortOption('A', 'acls');
/**
* Set the xattrs flag to preserve the extended attributes for the files
* transmitted.
*
* @function
* @name xattrs
* @memberOf Rsync.prototype
* @return {Rsync}
*/
exposeShortOption('X', 'xattrs');
/**
* Set the devices flag to preserve device files in the transfer.
*
* @function
* @name devices
* @memberOf Rsync.prototype
* @return {Rsync}
*/
exposeShortOption('devices');
/**
* Set the specials flag to preserve special files.
*
* @function
* @name specials
* @memberOf Rsync.prototype
* @return {Rsync}
*/
exposeShortOption('specials');
/**
* Set the times flag to preserve times for the files in the transfer.
*
* @function
* @name times
* @memberOf Rsync.prototype
* @return {Rsync}
*/
exposeShortOption('t', 'times');
// our awesome export product
const rsync = (...args) => {
return new Rsync(...args);
};
module.exports = rsync;
module.exports.Rsync = Rsync;