Sets the root directory path for the OpenComic AI package. This is primarily used in bundled or packaged applications where the package location differs from the default.
Syntax
OpenComicAI.setDirname(dirname: string): void
Parameters
Path to the package root directory. Can be absolute or relative.
Returns
void - This method does not return a value.
Behavior
- The path is resolved to an absolute path automatically
- Used internally to locate binaries and resources
- Essential for bundled applications where
__dirname may not reflect the actual package location
Example
import OpenComicAI from '@opencomic/ai-bin';
import { fileURLToPath } from 'url';
import { dirname } from 'path';
// ES modules pattern
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
OpenComicAI.setDirname(__dirname);
Use cases
Electron applications
import { app } from 'electron';
// Set dirname to the app's resource path
OpenComicAI.setDirname(app.getAppPath());
Packaged applications
// When using pkg or similar bundlers
OpenComicAI.setDirname(process.cwd());
Source
Defined in index.mts:769-773