Skip to content

Commit

Permalink
fix(modules): 修复直接在资源管理器上创建文件, 选中选项丢失问题.
Browse files Browse the repository at this point in the history
  • Loading branch information
czfadmin committed Sep 7, 2024
1 parent 4d7a7d2 commit 813452a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
5 changes: 4 additions & 1 deletion src/services/command-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -308,9 +308,12 @@ export default class CommandService implements Disposable {
window.onDidEndTerminalShellExecution(e => {
if (e.execution === this._execution) {
this._logger.info(
`execute command successfully!`,
`Command executed successfully!`,
e.execution.commandLine,
);
window.showInformationMessage(
`The \`${commandLine}\` was executed successfully!`,
);
}
}),
);
Expand Down
17 changes: 13 additions & 4 deletions src/utils/modules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,20 +113,30 @@ export async function getModulesQuickPick2(modules: IModule[]) {
return modules.find(module => module.name === selectedModule.label);
}

/**
*
* @param project 用户选择的子项目
* @param p 选择的文件上下文, 当直接在资源管理器视图中右键操作为undefined
* @returns
*/
export async function checkoutFolderIsModule(project?: INestProject, p?: Uri) {
if (!p) {
return;
return [];
}

if (fs.statSync(p.fsPath).isFile()) {
return;
return [];
}

let _modules: IModule[] = [];

// 从当前的项目中的sourceRoot下选择对应的module出来
const cwd = !project
? p.fsPath
: Uri.joinPath(project.workspace.uri, project.root || '').fsPath;

const entries = fg.globSync([`**/*.module.(t|j)s`], {
cwd: !project ? p.fsPath : Uri.joinPath(p, project.name).fsPath,
cwd: cwd,
deep: 4,
dot: false,
absolute: true,
Expand All @@ -146,6 +156,5 @@ export async function checkoutFolderIsModule(project?: INestProject, p?: Uri) {
});
}
}
console.log(_modules);
return _modules;
}

0 comments on commit 813452a

Please sign in to comment.