Code Monkey home page Code Monkey logo

tasuku's Issues

Access `warning`

If a completed task has a warning set, the parent should be able to check it to determine whether the task output can be cleared:

const result = task(...);

if (!result.warning) {
	result.clear();
}

Able to clear/unmount tasuku when top-level task throws error.

Is your feature request related to a problem?

When top-level task body throws, there are two issues:

Tasuku eats my stack trace
Tasuku does not allow me to intercept console (#16) when mounted.

Describe the solution you'd like

Not sure if I want to see the stack trace anywhere by default, but
I'd love to be able to clear/unmount tasuku completely in case error happens inside top-level task and fall back to own error handling.

Recommended way to use prompts?

Is your feature request related to a problem?

Not exactly - I currently have a CLI app that's using listr2, but tasuku looks nicer in that each task can have a return value, rather than listr2 which relies on mutating the context, which isn't as type safe.

listr2 has a specific prompt adapter. I'm not sure if tasuku would need an adapter, but it could be useful to have a docs suggestion of how you would recommend integrating enquirer or something

Describe the solution you'd like

What would be really great, is some sort of cleye x taskuku x enquirer thing. Where cleye defines its arguments/flags, andtasuku adds tasks to prompt the user for those arguments if they haven't been defined already. It could be built in userland, but wondered if there'd be interest in incorporating here.

Describe alternatives you've considered

DIY - just install enquirer.

Additional context

Group tasks from a generator

Is your feature request related to a problem?

I have a large dataset that I want to process as a grouped set of tasks. task.group forces me to create 1 function per task to run, it is slow and no efficient for memory.

Describe the solution you'd like

It would be more efficient to have something like task.map that takes a generator or an array of data, as well as a function to execute for each record.

example:

const data = function*() {
  yield 'a';
  yield 'b';
  yield 'c';
};

// or
// data = ['a', 'b', 'c'];

task.map(data, (task, item)=> task(item, () => 
  // so something
}));

Task.map can also manage concurrency and invoke the next function only when a seat is freed:

const data = function*() {
  yield 'a';
  yield 'b';
  yield 'c';
};
task.map(
  data, 
  (task, item)=> task(item, () => 
  // so something
  }),
  {concurrency: 2}
);

I'm happy to send a PR for this

Export types

I want to pass the task object to another function, like so.

import tsk, { TaskFunction } from 'tasuku'

async function scanPage(page: number, task: TaskFunction) {
    .......
    task.setOutput(`Scanning page ${page}...`)
    ........
}

tsk(
    'Scanning page',
    async (task) => {
        await scanPage(1, task)
    }
)

This doesn't work because TaskFunction is not exported.
Great library otherwise though, congrats, I switched from listr2

Redraw glitch when list of task is long

Bug description

This is a visual bug. When the list of items is bigger than the screen height, the list starts glitching.

2021-11-30 09 55 01

Reproduction

const task = require("tasuku");

(async function test() {
  let iteration = 0;
  while (true) {
    await task(
      `Run ${iteration} -- with long text it is more visible`,
      () => new Promise((resolve) => setTimeout(() => resolve(), 100))
    );
    iteration++;
  }
})();

Environment

  • tasuku version: 1.0.2
  • Operating System: MacOS 12.0.1 with ITerm2 3.4.12
  • Node version: 14.18.0 and 15.14.0 (inside docker)

Add esModuleInterop typescript option

Is your feature request related to a problem?

No

Describe the solution you'd like

When I install and use the tasuku library with typscript project
I have written code following this library document.

But I faced is not a function error and I founded issue point.

import task from "tasuku"

// it same below code without esModuleExport
const task = require("tasuku").default;

So I printed it and that is undefined.

Describe alternatives you've considered

Of course, it is not an important issue.

But How about the option was left in the readme.md?
I think it would be greater before then.

And I'm using this library very useful! thanks 😄

Additional context

Unable to output message after task message

Bug description

I want to output a message AFTER all the tasks have run, but it seems Tasuku somehow always hijacks the order of messages. I tried to use .then() and await the task itself, but no success...

How can I ensure my message is displayed AFTER the task messages?

Reproduction

import task from 'tasuku';

const delay = (ms) => {
    return new Promise(function(resolve) {
        setTimeout(resolve, ms);
    });
}

const response = await
  task( `My task`, () => (delay(100)))
  .then(() => {
    console.log('THEN command');
  });

console.log('should print after response, no?');

Output

Screenshot 2022-04-08 at 11 59 06

Environment

  • tasuku version: 1.0.2
  • Operating System: OSX Monterey 12.2.1
  • Node version: v14.18.2
  • Package manager (npm/yarn/pnpm) and version:

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.