-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
55 lines (42 loc) · 1.28 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
/* jshint node: true, esversion: 6 */
const analytics = require('./lib/analytics.js');
function handleSettings (opts) {
let settings = {};
if (typeof opts === 'string') {
const args = [].slice.call(arguments);
settings.id = args[0];
settings.input = args[1];
settings.output = args[2];
} else {
settings = opts;
}
if (!settings.input || typeof settings.input !== 'string') {
settings.input = './index.html';
}
if (!settings.output || typeof settings.output !== 'string') {
settings.output = settings.input;
}
return settings;
}
function create (opts) {
const settings = handleSettings.apply(null, [].slice.call(arguments));
analytics(settings.id, settings.input, settings.output, settings.bin || false);
}
module.exports = create;
/*
USAGE:
var twga = require('tw-analytics');
// option 1
twga.id = 'UA-XXXX-Y';
twga.input = 'index.html';
twga.output = 'dist/index.html'
twga.analytics();
// option 2
twga.analytics('UA-XXXX-Y', 'index.html', 'dist/index.html');
// option 3
twga.analytics({
id : 'UA-XXXX-Y',
input : 'index.html',
output : 'dist/index.html'
});
*/