forked from furkleindustries/inklecate-node
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexecute.js
34 lines (27 loc) · 946 Bytes
/
execute.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
const log = console.log;
const baseDEBUG = require('./DEBUG');
const executableHandler = require('./executableHandler');
const getCacheFilepath = require('./getCacheFilepath');
module.exports = (args) => {
const DEBUG = args.DEBUG || baseDEBUG;
const countAllVisits = args.countAllVisits;
const inputFilepath = args.inputFilepath;
const isCaching = args.isCaching || !args.outputFilepath;
const outputFilepath = isCaching ?
getCacheFilepath(args.inputFilepath) :
args.outputFilepath;
if (outputFilepath === inputFilepath) {
throw new Error('Output filepath was the same as input filepath. Aborting to prevent any potential data loss.')
}
const verbose = args.verbose;
const fullArgs = {
countAllVisits,
inputFilepath,
isCaching,
outputFilepath,
verbose,
DEBUG,
};
DEBUG && log('inklecate-node is using an executable inklecate.', fullArgs);
return executableHandler(fullArgs);
};