Skip to content

Commit

Permalink
Fix node executor loading plugins on windows & linux
Browse files Browse the repository at this point in the history
  • Loading branch information
abrenneke committed Oct 18, 2023
1 parent 9766d7f commit dbcd6ba
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions packages/app-executor/bin/executor.mts
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,28 @@ import { type RivetPluginInitializer } from '@ironclad/rivet-core';
import yargs from 'yargs';
import { hideBin } from 'yargs/helpers';
import { P, match } from 'ts-pattern';
import { getAppDataPath } from 'appdata-path';
import { join } from 'node:path';
import { access, readFile } from 'node:fs/promises';
import { platform, homedir } from 'node:os';

const datasetProvider = new DebuggerDatasetProvider();

// Roughly https://github.com/demurgos/appdata-path/blob/master/lib/index.js but appdata local and .local/share, try to match `dirs` from rust
function getAppDataLocalPath() {
const identifier = 'com.ironcladapp.rivet';
return match(platform())
.with('win32', () => join(homedir(), 'AppData', 'Local', identifier))
.with('darwin', () => join(homedir(), 'Library', 'Application Support', identifier))
.with('linux', () => join(homedir(), '.local', 'share', identifier))
.otherwise(() => {
if (platform().startsWith('win')) {
return join(homedir(), 'AppData', 'Local', identifier);
} else {
return join(homedir(), '.local', 'share', identifier);
}
});
}

const { port } = yargs(hideBin(process.argv))
.option('port', {
alias: 'p',
Expand Down Expand Up @@ -70,7 +86,7 @@ const rivetDebugger = startDebuggerServer({
registry.registerPlugin(initializedPlugin);
})
.with({ type: 'package' }, async (spec) => {
const localDataDir = getAppDataPath('com.ironcladapp.rivet');
const localDataDir = getAppDataLocalPath();
const pluginDir = join(localDataDir, `plugins/${spec.package}-${spec.tag}/package`);

const packageJsonPath = join(pluginDir, 'package.json');
Expand Down

0 comments on commit dbcd6ba

Please sign in to comment.