diff --git a/src/package-manager.ts b/src/package-manager.ts index 31ac152..30567b1 100644 --- a/src/package-manager.ts +++ b/src/package-manager.ts @@ -64,6 +64,11 @@ class PackageManager { const installationPath = relative(`../node_modules/${pkg.name}`); const tempPath = relative(`../.tmp/${pkg.name}/`); + // Ensure we have a node_modules folder local to the package. + if (!existsSync(installationPath)) { + mkdirSync(installationPath, { recursive: true }); + } + try { // Move the current installed package, and unpack the new package to node_modules. moveSync(installationPath, tempPath, { overwrite: true }); diff --git a/src/validation/plugin/plugin.ts b/src/validation/plugin/plugin.ts index 3d68dbe..0e68b79 100644 --- a/src/validation/plugin/plugin.ts +++ b/src/validation/plugin/plugin.ts @@ -5,9 +5,7 @@ import { JsonLocation, LocationRef } from "../../common/location"; import { JsonFileContext, JsonSchema } from "../../json"; import { isPredefinedLayoutLike, isValidPluginId } from "../../stream-deck"; -const r = createRequire(import.meta.url); -const layoutSchema = r("@elgato/schemas/streamdeck/plugins/layout.json"); -const manifestSchema = r("@elgato/schemas/streamdeck/plugins/manifest.json"); +const nodeRequire = createRequire(import.meta.url); /** * Suffixed associated with a plugin directory. @@ -43,9 +41,9 @@ class ManifestJsonFileContext extends JsonFileContext { * @param path Path to the manifest file. */ constructor(path: string) { - super(path, new JsonSchema(manifestSchema)); + super(path, new JsonSchema(nodeRequire("@elgato/schemas/streamdeck/plugins/manifest.json"))); - const compiledLayoutSchema = new JsonSchema(layoutSchema); + const compiledLayoutSchema = new JsonSchema(nodeRequire("@elgato/schemas/streamdeck/plugins/layout.json")); this.value.Actions?.forEach((action) => { if (action.Encoder?.layout !== undefined && !isPredefinedLayoutLike(action.Encoder?.layout.value)) { const filePath = resolve(dirname(path), action.Encoder.layout.value);