如何在 VS 代码 extension.js 中获取我的 Angular 项目文件夹路径。我试过但没有工作。例如我在 Visual Studio 代码中打开的 Angular 项目名称“universe”和“bookworld”。
Universe - 项目文件夹名称
-e2e
-node_modules
-src
-angular.json
-package.json
-package-lock.json
-README
-tsconfig.json
-tslint.json
bookworld - 项目文件夹名称
-e2e
-node_modules
-src
-angular.json
-package.json
-package-lock.json
-README
-tsconfig.json
-tslint.json
扩展.js:
const vscode = require('vscode');
const path = require('path');
function activate(context) {
const fullPath = path.dirname("c://mamp/htdocs/projects/ps/src/app/app.component.html");
const regexResp = /^(.*?)node_modules/.exec(fullPath);
const nodemodulesPath = regexResp ? regexResp[1] : fullPath;
console.log(nodemodulesPath );
//Example if i open package.json from universe in vs code project output should be like var currentprojectfolderpath =c://mamp/htdocs/main/universe
//Example if i open tslint.json from universe project in vs code output should be like var currentprojectfolderpath =c://mamp/htdocs/main/bookworld
}
如何获取当前打开文件的项目文件夹路径?