diff --git a/README.md b/README.md index 151c6b5..be2585f 100644 --- a/README.md +++ b/README.md @@ -49,6 +49,7 @@ inshellisense supports the following shells: - [fish](https://github.com/fish-shell/fish-shell) - [pwsh](https://github.com/PowerShell/PowerShell) - [powershell](https://learn.microsoft.com/en-us/powershell/scripting/windows-powershell/starting-windows-powershell) (Windows Powershell) +- [cmd](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/cmd) _(experimental)_ ## Contributing diff --git a/src/runtime/template.ts b/src/runtime/template.ts index 96cb0fa..f08d020 100644 --- a/src/runtime/template.ts +++ b/src/runtime/template.ts @@ -2,6 +2,7 @@ // Licensed under the MIT License. import fsAsync from "node:fs/promises"; +import log from "../utils/log.js"; const filepathsTemplate = async (cwd: string): Promise => { const files = await fsAsync.readdir(cwd, { withFileTypes: true }); @@ -28,15 +29,20 @@ export const runTemplates = async (template: Fig.TemplateStrings[] | Fig.Templat return ( await Promise.all( templates.map(async (t) => { - switch (t) { - case "filepaths": - return await filepathsTemplate(cwd); - case "folders": - return await foldersTemplate(cwd); - case "history": - return historyTemplate(); - case "help": - return helpTemplate(); + try { + switch (t) { + case "filepaths": + return await filepathsTemplate(cwd); + case "folders": + return await foldersTemplate(cwd); + case "history": + return historyTemplate(); + case "help": + return helpTemplate(); + } + } catch (e) { + log.debug({ msg: "template failed", e, template: t, cwd }); + return []; } }), ) diff --git a/src/utils/shell.ts b/src/utils/shell.ts index d78e944..cf9c0d8 100644 --- a/src/utils/shell.ts +++ b/src/utils/shell.ts @@ -19,9 +19,14 @@ export enum Shell { Cmd = "cmd", } -export const supportedShells = [Shell.Bash, process.platform == "win32" ? Shell.Powershell : null, Shell.Pwsh, Shell.Zsh, Shell.Fish].filter( - (shell) => shell != null, -) as Shell[]; +export const supportedShells = [ + Shell.Bash, + process.platform == "win32" ? Shell.Powershell : null, + Shell.Pwsh, + Shell.Zsh, + Shell.Fish, + process.platform == "win32" ? Shell.Cmd : null, +].filter((shell) => shell != null) as Shell[]; export const userZdotdir = process.env?.ZDOTDIR ?? os.homedir() ?? `~`; export const zdotdir = path.join(os.tmpdir(), `is-zsh`);