Open erhant opened 1 week ago
I don't know if the typescript compiler handles importing jsons differently than normal node.js but I did this on the circuitscan cli:
import {readFileSync} from 'node:fs';
import {dirname, join} from 'node:path';
import {fileURLToPath} from 'node:url';
// Recreate old common.js __dirname global
const __dirname = dirname(fileURLToPath(import.meta.url));
function getPackageJson() {
return JSON.parse(readFileSync(join(__dirname, '../package.json'), 'utf8'));
}
program
.version(getPackageJson().version);
hmm, also people on the web (stackoverflow) advise against this (i.e. readFile to JSON.parse), thanks for the suggestion though! I will try a few things 🙏🏻
This can be used at the top:
Then, at the bottom:
Not sure if that
package.json
can cause any trouble though, mixed comments on the web.