From d21d38e947a5c2015008595521e6cc5ac9f5b90e Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Wed, 1 Apr 2020 11:21:01 +0200 Subject: [PATCH] cli: make package.json reading absolute --- packages/cli/src/index.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/cli/src/index.ts b/packages/cli/src/index.ts index 3eafc6dc6b..08f14d3c00 100644 --- a/packages/cli/src/index.ts +++ b/packages/cli/src/index.ts @@ -17,6 +17,7 @@ import program from 'commander'; import chalk from 'chalk'; import fs from 'fs'; +import { resolve as resolvePath } from 'path'; import createAppCommand from './commands/create-app/createApp'; import createPluginCommand from './commands/create-plugin/createPlugin'; import watch from './commands/watch-deps'; @@ -29,7 +30,9 @@ import pluginServe from './commands/plugin/serve'; import { exitWithError } from './helpers/errors'; const main = (argv: string[]) => { - const packageJson = JSON.parse(fs.readFileSync('package.json', 'utf-8')); + const packageJson = JSON.parse( + fs.readFileSync(resolvePath(__dirname, '../package.json'), 'utf-8'), + ); program.name('backstage-cli').version(packageJson.version ?? '0.0.0');