-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerate
executable file
·61 lines (55 loc) · 1.76 KB
/
generate
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
#!/usr/bin/env node
var vcodeName = ["code", "code-insiders"];
var originalYourCode = process.argv[2].toString();
var fileName = (process.argv[3] || "README") + ".md";
var yourCode = originalYourCode.toLowerCase();
if (!vcodeName.includes(yourCode)) {
console.error(" 🚨 You RUN " + originalYourCode + " ");
console.log(
" 🚑 By DEFAULT the command will be " +
vcodeName[0] +
" or " +
vcodeName[1] +
""
);
process.exit(1);
}
function PathINfo() {
console.log(
" May be vs code Executable is not avalible in your path, \n👉 Try Running " +
vcodeName[0] +
" --help or " +
vcodeName[1] +
" --help in your shell. \n If you get back help command of vscode , it's in path & problem is someother. \n📖 If not refer vscode docs for integrating to your $PATH"
);
}
const { spawn, spawnSync } = require("child_process");
process.on("error", function(err) {
console.log("Error running Scripts");
});
var result = spawnSync(yourCode, ["--list-extensions"]);
if (result.error) {
console.error("💥", result.error);
PathINfo();
process.exit(1);
}
var list =
"## MY VS CODE EXTENSION \n ____ \n Generated Using [vscode-extension-backup-generator](https://github.com/saravntbe/vscode-extension-backup-generator) \n ____ \n";
list += String(result.stdout)
.split("\n")
.filter(Boolean)
.map(
x => `- [${x}](https://marketplace.visualstudio.com/items?itemName=${x})`
)
.join("\n");
// write to a md file
var path = require("path").resolve(process.cwd(), fileName);
var fs = require("fs").createWriteStream(path);
fs.write(list);
fs.on("close", function(e) {
process.exit(1);
});
console.log("⏳ Writing to a " + fileName + " ... ");
process.on("exit", function(e) {
console.log(" 🎉 Success ! ");
});