-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmcopy.js
More file actions
24 lines (22 loc) · 987 Bytes
/
mcopy.js
File metadata and controls
24 lines (22 loc) · 987 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
'use strict';
const parseArguments = require('./lib/parseArguments');
const defaultOptions = require('./lib/defaultOptions');
const ResolveSourcesCollection = require('./lib/ResolveSourcesCollection');
const ResolveDestinationsCollection = require('./lib/ResolveDestinationsCollection');
const CopyCollection = require('./lib/CopyCollection');
module.exports = function (...args) {
// Parse the inputs
let {jobs, opt} = parseArguments(args);
// Sanitise the options
opt = defaultOptions(opt);
// Create job collections
let sourcesCollection = new ResolveSourcesCollection(opt);
let destinationsCollection = new ResolveDestinationsCollection(opt);
let copyCollection = new CopyCollection(opt);
// Chain the collections
sourcesCollection.chain(destinationsCollection).chain(copyCollection);
// Prime the sourcesCollection with the input jobs
jobs.forEach((job) => sourcesCollection.seedJob(job));
// Return the collection
return sourcesCollection;
};