Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | 1x 1x 1x 1x 1x | import { readJSON } from "fs-extra";
import { glob } from "lib/helpers/glob";
import { join, dirname, relative } from "path";
import { InstalledPluginData } from "./types";
import { pathToPosix } from "shared/lib/helpers/path";
export const getPluginsInProject = async (projectPath: string) => {
const projectRoot = dirname(projectPath);
const pluginPaths = await glob("**/plugin.json", {
cwd: projectRoot,
absolute: true,
});
const plugins: InstalledPluginData[] = [];
for (const pluginPath of pluginPaths) {
try {
const pluginJSON = await readJSON(pluginPath);
if ("version" in pluginJSON && typeof pluginJSON.version === "string") {
plugins.push({
path: pathToPosix(relative(join(projectRoot, "plugins"), pluginPath)),
version: pluginJSON.version,
});
}
} catch {
console.error("Error: Unable to parse " + pluginPath);
}
}
return plugins;
};
|