Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including cli-task with all npm packages installed. Try it out:

var cliTask = require("cli-task")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

cli-task v0.7.5

Task runner for developers minimalists

cli-task

Task runner for developers minimalists

Install

$ npm install cli-task

Usage

const execa = require('execa');
const chalk = require('chalk');
const task = require('cli-task');
const jetpack = require('fs-jetpack');
const tmpPath = path.join(os.tmpdir(), 'dependency-size');

task()
    .add({
        name: 'init npm folder',
        exec: () => {
            return execa('npm', [
                'init',
                '--force'
            ], {
                cwd: tmpPath
            });
        }
    })
    .add({
        name: 'install dependency',
        exec: (state) => {
            return execa('npm', [
                'install',
                state.argv._[0]
            ], {
                cwd: tmpPath
            });
        }
    })
    .add({
        name: 'measure size',
        exec: (state) => {
            return jetpack.inspectTreeAsync(tmpPath).then(tree => {
                console.log(chalk.white(prettyBytes(tree.size)));
            });
        }
    })
    .run();

API

task.add(options)

Add a step to the task

options

Type: Object

name

Type: string

The name of the task to be displayed when being printed on the screen.

exec

Type: Function

The callback function which will be executed.

task.run()

Executes the task

Metadata

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free