diff --git a/src/bin/index.ts b/src/bin/index.ts index da9ddf6..52fffb4 100644 --- a/src/bin/index.ts +++ b/src/bin/index.ts @@ -1,9 +1,9 @@ import { formatMessage } from '../helpers/format-message'; import { run } from '../utils/run'; import { log } from '../tasks/stdio/log'; +import { constants } from '../constants'; import main from './main'; import { NullaryFn } from 'type-core'; -import { loadPackage } from 'cli-belt'; import { attach, options as _options, resolver, add } from 'exits'; export interface BinOptions { @@ -22,16 +22,16 @@ export interface BinOptions { */ export async function bin(options?: BinOptions): Promise { try { - const pkg = await loadPackage(__dirname, { title: false }); const opts = Object.assign( { - bin: 'kpo', - file: 'kpo.tasks.js', - description: pkg.description || '', - version: pkg.version || 'Unknown' + bin: constants.bin, + file: constants.file, + description: constants.description, + version: constants.version }, options ); + const task = await main({ argv: process.argv.slice(2) }, opts); const cbs: NullaryFn[] = []; diff --git a/src/constants.ts b/src/constants.ts new file mode 100644 index 0000000..ba8bd98 --- /dev/null +++ b/src/constants.ts @@ -0,0 +1,8 @@ +import pkg from '../package.json'; + +export const constants = { + bin: 'kpo', + file: 'kpo.tasks.js', + description: pkg.description || '', + version: pkg.version || 'Unknown' +}; diff --git a/src/tasks/reflection/lift.ts b/src/tasks/reflection/lift.ts index ae459e3..a110ac3 100644 --- a/src/tasks/reflection/lift.ts +++ b/src/tasks/reflection/lift.ts @@ -3,6 +3,7 @@ import { parseToRecord } from '../../helpers/parse'; import { getAbsolutePath } from '../../helpers/paths'; import { isCancelled } from '../../utils/is-cancelled'; import { run } from '../../utils/run'; +import { constants } from '../../constants'; import { select } from '../transform/select'; import { write } from '../filesystem/write'; import { print } from '../stdio/print'; @@ -38,7 +39,7 @@ export interface LiftOptions { export function lift(tasks: Task.Record, options?: LiftOptions): Task.Async { return async (ctx: Context): Promise => { const opts = Object.assign( - { purge: false, mode: 'default', bin: 'kpo' }, + { purge: false, mode: 'default', bin: constants.bin }, options ); diff --git a/src/tasks/reflection/list.ts b/src/tasks/reflection/list.ts index 109a28c..8ac9083 100644 --- a/src/tasks/reflection/list.ts +++ b/src/tasks/reflection/list.ts @@ -1,5 +1,6 @@ import { Task, Context } from '../../definitions'; import { parseToArray } from '../../helpers/parse'; +import { constants } from '../../constants'; import { print } from '../stdio/print'; import { Empty } from 'type-core'; import { into } from 'pipettes'; @@ -24,7 +25,7 @@ export function list( map?: (name: string, route: string[]) => string[] ): Task.Sync { return (ctx: Context): void => { - const opts = Object.assign({ bin: 'kpo' }, options); + const opts = Object.assign({ bin: constants.bin }, options); const items = parseToArray(tasks); const maxRouteLength = items.reduce( (acc, item) => (acc > item.route.length ? acc : item.route.length),