-
Notifications
You must be signed in to change notification settings - Fork 0
/
instrumenter.js
58 lines (49 loc) · 1.64 KB
/
instrumenter.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
/**
* @description Instruments all JS functions of a project with logging
* information. Relies on Esprima parser to detect all JS functions.
*
* The instrumentation functions can be found in the js_editor.js
* Currently it uses the instrumentation_log function which makes a
* request to the instrumentation_server; which will store all alive functions
* under _alive_functions.json
*
* @version 0.1
* @author Kishan Nirghin
* @Date 05-02-2019
*
* @param <sourceFolder>
*/
'use strict';
const commandLineArgs = require('command-line-args');
const instrumenter = require("./instrumenter_runner");
require("./prototype_extension");
/* get the instrumenter options */
var options = {
remove: false,
file: false,
source: null,
label: null,
console: false,
unique: false
}
try {
var argv = commandLineArgs([
/* Force overrides of source code */
{ name: 'force', type: Boolean, alias: 'f' },
/* Source can either be a file or a folder */
{ name: 'source', type: String, defaultOption: true },
/* instrumented source folder output */
{ name: 'destination', type: String, alias: 'd' },
/* A label that should be included in every log */
{ name: 'label', type: String, alias: 'l' },
/* Echo the log to console only (no http request/ quicker/ performance) */
{ name: 'console', type: Boolean, alias: 'c' },
/* whether we should only log unique logs */
{ name: 'unique', type: Boolean, alias: 'u' }
]);
options.extend(argv);
} catch(exception) {
console.log(exception.message);
process.exit(1);
}
instrumenter.run(options);