-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
49 lines (47 loc) · 1.25 KB
/
app.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
/**********/
/* m@nish */
/**********/
const fs = require("fs");
fs.readFile("Arduino_VScode.json", (err, data) => {
if (!err) {
let json_data = JSON.parse(data);
// console.log(json_data);
let json_sublime = {
scope: "source.c",
completions: [],
};
// iterate it
for (let key in json_data) {
if (json_data.hasOwnProperty(key)) {
let Trigger = json_data[key].prefix;
let Content = json_data[key].body.slice(0, -2);
let Annotation = json_data[key].description;
let newCompletion = {
trigger: Trigger,
contents: Content,
annotation: Annotation,
kind: "markup",
};
// push it ^-^
json_sublime.completions.push(newCompletion);
}
}
// console.log(json_sublime);
let stringified_data = JSON.stringify(json_sublime);
// write it in new file
fs.writeFile(
"Arduino_Sublime.sublime-completions",
stringified_data,
(err) => {
if (err) console.log("Error generating file!");
console.log(
"Generated " +
json_sublime.completions.length +
" suggestions Successfully!"
);
}
);
} else {
console.log("Error accessing .json file");
}
});