More robust way to read package.json

This commit is contained in:
soulgalore 2023-02-25 12:53:27 +01:00
parent 0366038d5f
commit 6c58002130
1 changed files with 6 additions and 2 deletions

View File

@ -1,6 +1,7 @@
import { platform, release } from 'node:os';
import { env, version } from 'node:process';
import { join } from 'node:path';
import { join, resolve } from 'node:path';
import { fileURLToPath } from 'node:url';
import fs from 'node:fs/promises';
import dayjs from 'dayjs';
@ -20,7 +21,10 @@ import { parsePluginNames, loadPlugins } from './core/pluginLoader.js';
import * as urlSource from './core/url-source.js';
import * as scriptSource from './core/script-source.js';
const packageJson = JSON.parse(await fs.readFile('./package.json'));
const __dirname = fileURLToPath(new URL('.', import.meta.url));
const packageJson = JSON.parse(
await fs.readFile(resolve(join(__dirname, '..', 'package.json')))
);
const log = intel.getLogger('sitespeedio');
dayjs.extend(utc);