-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
47 lines (41 loc) · 1.36 KB
/
index.js
File metadata and controls
47 lines (41 loc) · 1.36 KB
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
// Get the project xml
if (process.argv.length < 4) {
console.error(`usage: ${process.argv[1]} <filename> <outfile>`);
process.exit(1);
}
const filename = process.argv[2];
const outfile = process.argv[3];
const fs = require('fs');
const projectString = fs.readFileSync(filename, 'utf8');
// Get the replay from the xml
const Project = require('./src/project')
const project = new Project(projectString);
const inquirer = require('inquirer');
project.selectOption = (ids, info) => {
const {baseIds, xmls, paths, event} = info;
const choices = xmls.map((xml, i) => {
return {
name: xml,
value: i
};
}).reverse();
const question = {
type: 'list',
name: 'selectedIndex',
choices,
message: `Which item should be used for arg ${baseIds[0]} (${paths[0].join('.')})?`
};
console.log();
console.log('Found event with ambiguous argument:');
const prettyEvent = event.pretty();
console.log(prettyEvent);
console.log();
console.log(ids);
return inquirer.prompt([question])
.then(answers => ids[answers.selectedIndex]);
};
project.repair()
.then(() => {
fs.writeFileSync(outfile, project.toString());
console.log('modified project written to ' + outfile);
});