-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathutils.js
More file actions
86 lines (77 loc) · 2.69 KB
/
utils.js
File metadata and controls
86 lines (77 loc) · 2.69 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
const vscode = require('vscode');
const { readFile, readFileSync, readdirSync, statSync, writeFileSync } = require("fs");
function getExtensionList(context) {
const res = vscode.extensions.all
.filter(e => !e.packageJSON.isBuiltin)
.map(e => {
return {
id: e.id,
uuid: e.packageJSON.uuid,
name: e.packageJSON.name,
publisher: e.packageJSON.publisher,
version: e.packageJSON.version,
};
});
return res;
};
const installExtensionList = async function (context, extensionList) {
for(let extInfo of extensionList){
console.log(`Installing ${extInfo.name}`);
vscode.window.showInformationMessage(`Installing ${extInfo.name}`);
await vscode.commands.executeCommand(
"workbench.extensions.installExtension",
`${extInfo.publisher}.${extInfo.name}`
);
}
vscode.window.showInformationMessage(`Installed all the extensions !!`);
};
// export const exportSetting = async function (context){
// const resData = JSON.stringify({
// 'settings.json': getUserSettings(context),
// 'keybindings.json': getKeyBinding(context),
// 'extensionList': getExtensionList(context),
// 'snippets': getSnippets(context),
// });
// const uri = await vscode.window.showSaveDialog({ defaultUri: vscode.Uri.file('vscode-setting-export.json') });
// if (!uri) {
// return false;
// }
// writeFileSync(uri.fsPath, resData);
// return true;
// };
// export const importSetting = async function (context){
// const uris = await vscode.window.showOpenDialog({
// canSelectMany: false,
// canSelectFolders: false,
// filters: {
// json: ['json']
// }
// });
// if (!uris || !uris.length) {
// return false;
// }
// const dataStr = readFileSync(uris[0].fsPath, 'utf-8');
// if (!dataStr) {
// vscode.window.showInformationMessage('导入失败');
// return false;
// }
// const data = JSON.parse(dataStr);
// if (data["settings.json"]) {
// await restoreUserSettings(context, data["settings.json"]);
// }
// if (data["keybindings.json"]) {
// await restoreKeyBinding(context, data["keybindings.json"]);
// }
// if (data.snippets) {
// await restoreSnippets(context, data.snippets);
// }
// if (data["extensionList"]) {
// await restoreExtensionList(context, data["extensionList"]);
// }
// vscode.commands.executeCommand("workbench.action.reloadWindow");
// return true;
// };
module.exports = {
getExtensionList,
installExtensionList
}