From ad142f6d9918367bf5f2f488168c658f25f664c5 Mon Sep 17 00:00:00 2001 From: Rafa Mel Date: Thu, 1 Apr 2021 09:29:32 +0200 Subject: [PATCH] fix: propagate bin name at lift and list subcommand and task --- src/bin/kpo.ts | 2 +- src/bin/lift.ts | 3 ++- src/bin/main.ts | 4 ++-- src/tasks/reflection/lift.ts | 4 ++-- src/tasks/reflection/list.ts | 4 +--- 5 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/bin/kpo.ts b/src/bin/kpo.ts index 4a76eb5..5c9d3ae 100644 --- a/src/bin/kpo.ts +++ b/src/bin/kpo.ts @@ -1,4 +1,4 @@ #!/usr/bin/env node import { bin } from './index'; -bin({ bin: 'kpo' }); +bin(); diff --git a/src/bin/lift.ts b/src/bin/lift.ts index 15e65ae..5960073 100644 --- a/src/bin/lift.ts +++ b/src/bin/lift.ts @@ -65,7 +65,8 @@ export default async function bin( print(), lift(params.record, { purge: cmd['--purge'], - mode: cmd['--mode'] as any + mode: cmd['--mode'] as any, + bin: opts.bin }) ); } diff --git a/src/bin/main.ts b/src/bin/main.ts index 0b74181..1a17e6e 100644 --- a/src/bin/main.ts +++ b/src/bin/main.ts @@ -27,7 +27,7 @@ export default async function main( const pkg = await loadPackage(__dirname, { title: true }); const help = indent` - ${pkg.description ? chalk.bold(pkg.description) : ''} + ${pkg.description ? chalk.bold(pkg.description) : ''} Usage: $ ${opts.bin} [options] [command] @@ -161,7 +161,7 @@ export default async function main( log('debug', 'Working directory:', process.cwd()), log('info', chalk.bold(opts.bin), chalk.bold.blue(':list')), print(), - list(record) + list(record, { bin: opts.bin }) ), withContext ); diff --git a/src/tasks/reflection/lift.ts b/src/tasks/reflection/lift.ts index 6387290..6ee1a35 100644 --- a/src/tasks/reflection/lift.ts +++ b/src/tasks/reflection/lift.ts @@ -49,8 +49,8 @@ export function lift(tasks: Task.Record, options?: LiftOptions): Task.Async { } const content = await fs.readFile(pkgPath); const pkg = JSON.parse(content.toString()); - const pkgScripts: Members = pkg.scripts || {}; + const taskScripts = into( tasks, parseToRecord.bind(null, { include: null, exclude: null }), @@ -59,7 +59,7 @@ export function lift(tasks: Task.Record, options?: LiftOptions): Task.Async { return keys.reduce( (acc: Members, name) => ({ ...acc, - [name]: opts.bin ? `${opts.bin} ${name} --` : `${name} --` + [name]: `${opts.bin} ${name} --` }), {} ); diff --git a/src/tasks/reflection/list.ts b/src/tasks/reflection/list.ts index dcb666e..109a28c 100644 --- a/src/tasks/reflection/list.ts +++ b/src/tasks/reflection/list.ts @@ -35,9 +35,7 @@ export function list( ? items.map((item) => map(item.name, item.route)) : items.map((item) => { return [ - (opts.bin ? `${opts.bin} ` : '') + - chalk.bold(item.name) + - ' '.repeat(4), + opts.bin + ' ' + chalk.bold(item.name) + ' '.repeat(4), ...Array(item.route.length).fill(''), item.route[item.route.length - 1], ...Array(maxRouteLength - item.route.length).fill('')