Skip to content

Commit

Permalink
Merge pull request #9 from edumudu/fix/get-right-version
Browse files Browse the repository at this point in the history
Fix the version showed when using the `--version flag`
  • Loading branch information
edumudu authored Apr 9, 2022
2 parents ea3ecde + f1f024f commit 131ca6c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
9 changes: 7 additions & 2 deletions packages/cli/bin/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@ import yargs from 'yargs';
import { hideBin } from 'yargs/helpers';
import chalk from 'chalk';

import { modulesRoot, packageDir, packagesInfoPath } from '../config/paths.mjs';
import {
modulesRoot,
packageDir,
packagesInfoPath,
currentVersion,
} from '../config/paths.mjs';

import { commands } from '../commands/index.mjs';

Expand All @@ -18,5 +23,5 @@ yargs(hideBin(process.argv))
.demandCommand(1, chalk.red('You need to specify a command'))
.strict()
.help()
.version()
.version(currentVersion)
.parse();
5 changes: 5 additions & 0 deletions packages/cli/config/paths.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import path from 'path';
import os from 'os';
import { createRequire } from 'module';

const require = createRequire(import.meta.url);
const { version } = require('../package.json');

export const packageDir = path.join(os.homedir(), '.loctry');
export const modulesRoot = path.join(packageDir, 'node_modules');
export const packagesInfoPath = path.join(packageDir, 'packages-info.json');
export const currentVersion = version;

0 comments on commit 131ca6c

Please sign in to comment.