Skip to content

Commit

Permalink
fix: local installations failing when attempting to update validation…
Browse files Browse the repository at this point in the history
… rules
  • Loading branch information
GeekyEggo committed Apr 14, 2024
1 parent 9c41bd3 commit fa2db8d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
5 changes: 5 additions & 0 deletions src/package-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
Expand Down
8 changes: 3 additions & 5 deletions src/validation/plugin/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -43,9 +41,9 @@ class ManifestJsonFileContext extends JsonFileContext<Manifest> {
* @param path Path to the manifest file.
*/
constructor(path: string) {
super(path, new JsonSchema<Manifest>(manifestSchema));
super(path, new JsonSchema<Manifest>(nodeRequire("@elgato/schemas/streamdeck/plugins/manifest.json")));

const compiledLayoutSchema = new JsonSchema<Layout>(layoutSchema);
const compiledLayoutSchema = new JsonSchema<Layout>(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);
Expand Down

0 comments on commit fa2db8d

Please sign in to comment.