From 7326ff9939dc7aad3009614716425bcc3c72af4c Mon Sep 17 00:00:00 2001 From: Andy Edwards Date: Wed, 6 Dec 2017 23:47:08 -0600 Subject: [PATCH] feat: support task descriptions --- README.md | 41 ++++++++++++++++++++++++++++++++++++++++ package.json | 1 + src/Promake.js | 7 ++++++- src/Rule.js | 8 ++++++++ test/index.js | 8 ++++---- test/integration/promake | 8 ++++---- yarn.lock | 4 ++++ 7 files changed, 68 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 3e51349..1091feb 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,7 @@ Promise-based JS make clone that can target anything, not just files + [`targets`](#targets) + [`prerequisites`](#prerequisites) + [`args`](#args) + + [`description([newDescription])`](#descriptionnewdescription) + [`then(onResolved, [onRejected])`](#thenonresolved-onrejected) + [`catch(onRejected)`](#catchonrejected) * [The `Resource` interface](#the-resource-interface) @@ -36,6 +37,7 @@ Promise-based JS make clone that can target anything, not just files * [Pass args through to a shell command](#pass-args-through-to-a-shell-command) * [Make Tasks Prerequisites of Other Tasks](#make-tasks-prerequisites-of-other-tasks) * [Depend on Values of Environment Variables](#depend-on-values-of-environment-variables) + * [List available tasks](#list-available-tasks) - [Examples](#examples) * [Transpiling files with Babel](#transpiling-files-with-babel) * [Basic Webapp](#basic-webapp) @@ -149,6 +151,15 @@ actual file that exists, similar to a [phony target in `make`](https://www.gnu.o Task names take precedence over file names when specifying what to build in CLI options. +You can set the description for the task by calling [`.description()`](#descriptionnewdescription) +on the returned `Rule`. This description will be printed alongside the task +if you call the CLI without any targets. For example: +```js +task('clean', () => + require('fs-extra').remove('build') +).description('removes build output') +``` + ##### `name` The name of the task @@ -275,6 +286,12 @@ The normalized array of resources that must be made before running this rule. Any args for this rule (from the [CLI](#cliargv--processargv-options), usually) +### `description([newDescription])` + +Gets or sets the description of this rule. If you provide an argument, +sets the description and returns this rule. Otherwise, returns the +description. + ### `then(onResolved, [onRejected])` Starts running this rule if it isn't already, and calls `onResolved` when it finishes or `onReject` when it fails. @@ -425,6 +442,30 @@ envRule(buildEnv, ['NODE_ENV', 'BABEL_ENV']) rule(lib, [...src, buildEnv], () => exec('babel src/ --out-dir lib')) ``` +## List available tasks + +Run the CLI without specifying any targets. For instance if your +build file is `promake`, run: + +``` +> ./promake +promake CLI, version X.X.X +https://github.com/jcoreio/promake/tree/vX.X.X + +Usage: + ./