Git Product home page Git Product logo

grinder.dart's Introduction

Dart pub package

Dart workflows, automated.

Grinder consists of a library to define project tasks (e.g. test, build, doc) and a command-line tool to run them.

Getting Started

To start using grinder, add it to your dev_dependencies.

Defining Tasks

Tasks are defined entirely by Dart code allowing you to take advantage of the whole Dart ecosystem to write and debug them. Task definitions reside in a tool/grind.dart script. To create a simple grinder script, run:

pub run grinder:init

In general, grinder scripts look something like this:

import 'package:grinder/grinder.dart';

main(args) => grind(args);

@DefaultTask('Build the project.')
build() {
  log("Building...");
}

@Task('Test stuff.')
@Depends(build)
test() {
  new PubApp.local('test').run([]);
}

@Task('Generate docs.')
doc() {
  log("Generating docs...");
}

@Task('Deploy built app.')
@Depends(build, test, doc)
deploy() {
  ...
}

Any task dependencies (see @Depends above), are run before the dependent task.

Grinder contains a variety of convenience APIs for common task definitions, such as PubApp referenced above. See the API Documentation for full details.

Running Tasks

First install the grind executable:

pub global activate grinder

then use it to run desired tasks:

grind test
grind build doc

or to run a default task (see @DefaultTask above):

grind

or to display a list of available tasks and their dependencies:

grind -h

You can also bypass installing grind and instead use pub run grinder.

Passing parameters to tasks

In order to pass parameters to tasks from the command-line, you query the TaskArgs instance for your task invocation. For example:

grind build --release --mode=topaz

and:

@Task()
build() {
  TaskArgs args = context.invocation.arguments;
  bool isRelease = args.getFlag('release'); // will be set to true
  String mode = args.getOption('mode'); // will be set to topaz
  
  ...
}

would pass the flag release and the option mode to the build task.

You can pass flags and options to multiple tasks. The following command-line would pass separate flags and options to two different tasks:

grind build --release generate-docs --header=small

Disclaimer

This is not an official Google product.

Publishing automation

For information about our publishing automation and release process, see https://github.com/dart-lang/ecosystem/wiki/Publishing-automation.

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.