Skip to content

Commit

Permalink
fix: read package.json correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
ItzDerock committed Oct 20, 2022
1 parent 214872c commit 92d5495
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/generator/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,18 @@ import renderContent, { RenderType } from './renderers/content';
import { buildProfiles } from '../utils/buildProfiles';
import { scrollToMessage } from '../static/client';
import { readFileSync } from 'fs';
import path from 'path';

// read the package.json file and get the @derockdev/discord-components-core version
let discordComponentsVersion = "^3.5.0";

try {
const packageJSON = JSON.parse(readFileSync('./package.json', 'utf8'));
discordComponentsVersion = packageJSON.dependencies['@derockdev/discord-components-core'];
// eslint-disable-next-line no-empty
const packagePath = path.join(__dirname, '..', '..', 'package.json');
const packageJSON = JSON.parse(readFileSync(packagePath, 'utf8'));
discordComponentsVersion = packageJSON.dependencies['@derockdev/discord-components-core'] ?? discordComponentsVersion;
// eslint-disable-next-line no-empty
} catch {} // ignore errors


export type RenderMessageContext = {
messages: Message[];
channel: Channel;
Expand Down

0 comments on commit 92d5495

Please sign in to comment.