Code Monkey home page Code Monkey logo

task's Introduction

task

task is simple to full-featured async task runner

  • es6 task files
  • typescript task files
  • .env parsing
  • parallelized dependencies can speed some tasks
  • daemon restarts
  • watch mode

Install

# to run latest
git clone https://github.com/mgutz/task
cd task
npm link

# to run next, which may be outdated
npm install -g @mgutz/task@next

# stable is not yet available

Help

Task Manual

Quick Start

Edit Taskfile.js or Taskfile.ts. Does not need to be inside a node project

const sleep = ms => new Promise(resolve => resolve(), ms)

export const name = async ({prompt}) => {
  const answers = await prompt([{name: 'name', message: 'Name'}])
  console.log(`Hello, ${answers.name}!`)
}

export const clean = async () => {
  await sleep(1)
  console.log('clean')
}

export const build = {
  deps: [clean],
  run: () => {
    console.log('build')
  },
}

export const arg = ({argv}) => {
  console.log(argv._[0])
}

export const docs = () => {
  console.log('building docs')
}

// use shell spawn (shawn) to gracefully restart daemons
export const server = {
  run: async ({shawn}) => {
    return shawn(`node src/main.js`)
  },
  watch: ['src/**.js'],
}

export default {
  // runs `name` then ['clean', 'build'] and `docs` in parallel
  deps: [name, {p: [build, docs]}],
}

To run default: task

To invoke arg with an argument: task arg foo

To run server in watch mode: task server -w

To see which tasks will run: task build --dry-run

Configuration

task reads .taskrc configuration file from same directory as the Taskfile. .taskrc must be a node compatible Javascript file.

module.exports = {
  debug: true,
  file: 'Taskfile.mjs',
}

Be aware that some short flags are aliases for long flags on the command line. Use long flag names in .taskrc. For example, use file instead of f.

task --init creates an example .taskrc

GUI

GUI Manual

Testing

To run tests

task test

LICENSE

MIT Licensed

task's People

Contributors

ryanatkn avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar

task's Issues

anonymous deps not working

Task bah only prints 'foo', expected 'bar' and 'foo'

export function bah({event}) {
  console.log(`File changed: ${JSON.stringify(event)}`)
}


export default {
  bah: {
    deps: ['bar', 'foo'],
    watch: ['./*.txt']
  },
  bar: {
    deps: [() => console.log('bar')]
  },
  foo: () => {
    console.log("foo")
  }
}

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.