feat: add function and task to get version of used dependency

Fixes #20
This commit is contained in:
Karl-Philipp Wulfert
2019-07-05 13:21:50 +02:00
parent 9d3dd97830
commit 067a2011c0
2 changed files with 75 additions and 1 deletions

View File

@@ -16,8 +16,10 @@ import {Api} from '@openstapps/gitlab-api';
import {Logger} from '@openstapps/logger';
import * as commander from 'commander';
import {existsSync, readFileSync} from 'fs';
import {join} from 'path';
import {join, resolve} from 'path';
import {cwd, stdout} from 'process';
import {GITLAB_API_URL} from './configuration';
import {getUsedVersionMajorMinor} from './tasks/get-used-version';
import {remind} from './tasks/remind';
import {tidy} from './tasks/tidy';
import {unlabel} from './tasks/unlabel';
@@ -63,6 +65,17 @@ commander
Logger.ok('Done!');
});
commander
.command('get-used-version <dependency> [path]')
.action(async (dependency, path) => {
let fallbackPath = cwd();
if (typeof path === 'string' && path.length > 0) {
fallbackPath = resolve(path);
}
stdout.write(await getUsedVersionMajorMinor(fallbackPath, dependency), process.exit);
});
commander
.parse(process.argv);