projectHome修改为projectDir

This commit is contained in:
Pan Qiancheng 2024-10-25 14:03:14 +08:00
parent f0d0171108
commit 7af54d97d7
2 changed files with 9 additions and 3 deletions

View File

@ -210,7 +210,7 @@ export async function activate(context: vscode.ExtensionContext) {
const rootPath = workspaceFolders[0].uri.fsPath;
const projectPath = join(rootPath, './');
// 在根目录下创建oak.config.json文件
const content = JSON.stringify({ projectHome: './' }, null, 2);
const content = JSON.stringify({ projectDir: './' }, null, 2);
fs.writeFile(
vscode.Uri.file(join(projectPath, 'oak.config.json')),
Buffer.from(content)
@ -227,7 +227,13 @@ export async function activate(context: vscode.ExtensionContext) {
const uri = uris[0];
const contextFile = await fs.readFile(uri);
const config = JSON.parse(contextFile.toString()) as OakConfiog;
const projectHome = join(uri.fsPath, '..', config.projectHome);
if (!config.projectDir) {
vscode.window.showErrorMessage(
'oak.config.json文件中缺少projectDir字段'
);
return;
}
const projectHome = join(uri.fsPath, '..', config.projectDir);
// 设置projectHome
setProjectHome(projectHome);
// 通知已经启用

View File

@ -1,3 +1,3 @@
export type OakConfiog = {
projectHome: string;
projectDir: string;
}