tcmCommand
uses node:fs
tcm.path is the tcm executable, or a path to tcm's bin/tcm.js (run with Node), or a command line whose
words are separated by spaces, with "quotes" around a word that contains spaces.
import fs from "node:fs"; import * as vscode from "vscode"; export function tcmCommand(): string[] { const setting = vscode.workspace.getConfiguration("tcm").get("path", "tcm").trim(); // a file: tcm itself, or its bin/tcm.js (spaces in the path and all) if (fs.existsSync(setting)) return /\.(c|m)?(js|ts)$/.test(setting) ? ["node", setting] : [setting]; return [...setting.matchAll(/"([^"]*)"|(\S+)/g)].map((m) => m[1] ?? m[2]!); }