forked from Kishanjay/LacunaV2-evaluator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtodomvc_instrumenter.js
61 lines (50 loc) · 1.8 KB
/
todomvc_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
59
60
61
const puppeteer = require("puppeteer");
const path = require("path");
const fs = require('fs-extra');
var instrumenter = require("./dynamic-deadfunction-detector/instrumenter_runner");
var cwd = process.cwd();
process.chdir('./todomvc/tests');
var frameworkPathLookup = require('./todomvc/tests/framework-path-lookup');
var frameworks = frameworkPathLookup();
process.chdir(cwd);
const TODOMVC_DIR = "todomvc";
const EXAMPLES_DIR = "examples.lacunized";
const EXAMPLES_OUTPUT_DIR = "examples.lacunized.instrumented";
function start() {
createDestinationFolder(); // should work with EXAMPLES_OUTPUT_DIR after this
frameworks.forEach((framework) => {
let directory = generateFrameworkDirectory(framework);
var options = {
source: path.join(directory, 'index.html'),
destination: directory,
force: true,
label: framework.name,
unique: true,
}
try {
instrumenter.run(options);
} catch (error) {
console.log(error);
}
});
}
start();
/**
* Fetches the directory for a framework
*/
function generateFrameworkDirectory({path: frameworkPath}) {
frameworkPath = frameworkPath.splice(0, 8, EXAMPLES_OUTPUT_DIR); // append to examples
let pwdFrameworkPath = path.join(TODOMVC_DIR, frameworkPath);
return pwdFrameworkPath;
}
/**
* Creates and clears the new examples folder (that will be normalized)
*/
function createDestinationFolder() {
examplesSource = path.join(TODOMVC_DIR, EXAMPLES_DIR);
examplesDestination = path.join(TODOMVC_DIR, EXAMPLES_OUTPUT_DIR);
if (fs.existsSync(examplesDestination) && fs.lstatSync(examplesDestination).isDirectory()) {
fs.removeSync(examplesDestination);
}
fs.copySync(examplesSource, examplesDestination);
}