promote lib manage

This commit is contained in:
锦恢 2023-04-13 22:46:48 +08:00
parent 52349329df
commit 6ef036fa78
3 changed files with 21 additions and 4 deletions

View File

@ -1,5 +1,6 @@
import * as assert from 'assert';
import * as fs from 'fs';
import { hdlFile } from '../hdlFs';
import { Arch, PrjInfo, RawPrjInfo, resolve, toSlash } from './prjInfo';
@ -141,6 +142,22 @@ class OpeParam {
public resolvePathExtension(relPath: RelPath): AbsPath {
return resolve(this._extensionPath, relPath);
}
/**
* get User's property.json
*/
public getUserPrjInfo() {
const propertyJsonPath = this.propertyJsonPath;
const userPrjInfo = new PrjInfo();
if (fs.existsSync(propertyJsonPath)) {
const rawPrjInfo = hdlFile.readJSON(propertyJsonPath);
userPrjInfo.merge(rawPrjInfo);
} else {
// use default config instead
const rawPrjInfo = hdlFile.readJSON(this.propertyInitPath);
userPrjInfo.merge(rawPrjInfo);
}
}
};
const opeParam: OpeParam = new OpeParam();

View File

@ -145,6 +145,8 @@ class LibPick {
if (selectedPath && hdlPath.exist(selectedPath)) {
const ppyPath = hdlPath.join(opeParam.workspacePath, '.vscode', 'property.json');
// 抽象这块
let prjInfo = null;
// 如果存在,则读取用户的配置文件,否则使用默认的
if (!hdlPath.exist(ppyPath)) {
@ -152,11 +154,10 @@ class LibPick {
} else {
prjInfo = hdlFile.readJSON(ppyPath);
}
if (selectedPath.includes(this.commonQuickPickItem.path!)) {
// this is a module import from common, use relative path
const relPath = selectedPath.replace(this.commonQuickPickItem.path + '/', '');
const relPath = selectedPath.replace(this.commonQuickPickItem.path + '/', '');
appendLibraryCommonPath(relPath, prjInfo);
} else {
// this is a module import from custom, use absolute path

View File

@ -86,7 +86,6 @@ class PrjManage {
public initialise() {
}
}
const prjManage = new PrjManage();