vscode插件开发
导出插件:
1、执行npm install vsce -g –save vsce,安装vsce命令。
2、修改工程中的错误,有任何错误都不能完成打包(将Blob类型改成any)。
3、删除node_modules文件夹,执行npm install
4、执行vsce package
vsce package
安装
npm i vsce -g
执行系统命令
const exec = require('child_process').exec;
const child = exec('ll /webs | wc -l', (error, stdout, stderr) => {
console.log(`stdout: ${stdout}`);
console.log(`stderr: ${stderr}`);
if (error !== null) {
console.log(`exec error: ${error}`);
}
});
const cp = require("child_process");
let status = cp.exec(`${this.EGRET_COMMAND} ${command}`, { cwd: workspaceRoot });
status.stdout.on('data', (data) => {
this.showOutput(data);
});
status.stderr.on('data', (data) => {
this.showOutput(data);
});
判断平台
function platform() {
switch (process.platform) {
case 'darwin':
return macos;
case 'win32':
return windows;
case 'android':
if (process.env.PREFIX !== '/data/data/com.termux/files/usr') {
throw new Error('You need to install Termux for this module to work on Android: https://termux.com');
}
return termux;
default:
return linux;
}
}
获取当前文件夹 相对路径下的文件
const path = require('path');
const arch = require('arch');
path.join(__dirname, '../fallbacks/windows/clipboard_x86_64.exe')
插件开发文档:https://code.visualstudio.com/docs/extensions/overview
插件开发教程:http://blog.haoji.me/vscode-plugin-overview.html