Git Product home page Git Product logo

sake-core's Introduction

Sake

npm build dependencies downloads license chat

It is cold, but Β· we have Sake Β· and the hot spring

Sake is a build tool and task runner for JavaScript. Sake features an extensible core and support for modern JS. Inspired by Cake, Sake is the perfect DSL for building projects.

Features

  • Additional helpers to make writing tasks faster and more pleasant.
  • Generator based-control flow in tasks with full support for Promises.
  • Intutive CLI and automatic option parsing.
  • Plugin architecture with available plugins for many common build tasks.
  • Tasks can declare dependencies and be easily composed of and interact with other tasks.
  • Modern JS support:
    • Async/Await
    • ES modules
    • Generators
    • Promises

Install

npm install sake-core --save-dev

Usage

Typically Sake is used via it's command line interface which can be installed with npm install -g sake-cli. Once the sake command is available, you can begin writing a Sakefile and defining available tasks in your project.

Sakefile

Sake will search for a Sakefile with tasks defined for your current project. Sakefiles can be written in ES2015 JavaScript and support modules natively.

Optionally, you can write your Sakefile in CoffeeScript, which allows a very nice DSL-ish experience.

Examples

Async tasks

Async tasks are easy to declare, any task with an obvious callback will be treated as asynchronous. Add an additional argument called callback, cb, done or next and use it to indicate when your task is finished executing.

task 'compile:js', 'compile js', (done) ->
  exec 'coffee -bc app.coffee', done

task 'minify:js',   'minify js', (done) ->
  exec 'uglify-js --compress --mangle app.js > app.min.js', done

Promise tasks

You can also return a promise from your task and sake will automatically wait for it to resolve. Since executive returns a promise, this works too:

task 'compile:js', 'compile js', ->
  exec 'coffee -bc app.coffee'

Invoking multiple tasks

You can manually invoke tasks and string them together with callbacks:

task 'build', 'build project', ->
  invoke 'compile:js', ->
    invoke 'minify:js'

Declaring dependencies

Dependencies can be declared by adding an array of task names after your task's description.

task 'build', 'build project', ['compile:js', 'minify:js']

Serial tasks

You can also pass an array of tasks invoke and it will execute them in order for you:

task 'build', 'build project', (done) ->
  invoke ['compile:js', 'minify:js'], done

...or more explicitly using invoke.serial.

Parallel tasks

If you want to execute tasks in parallel you can use invoke.parallel.

task 'compile', 'compile css & js', (done) ->
  invoke.parallel ['compile:css', 'compile:js'], done

Detecting running tasks

You can check for running tasks using the running helper.

task 'watch', 'watch for changes and re-compile js', ->
  exec 'coffee -bcmw -o lib/ src/'

task 'watch:test', 'watch for changes and re-run tests', (options) ->
  invoke 'watch'

  require('vigil').watch __dirname, (filename, stats) ->
    return if running 'test'

    if /^test/.test filename
      invoke 'test', test: filename
    if /^src/.test filename
      invoke 'test'

Generator tasks

You can also use yield to wait for the value of a promise and eschew the use of callbacks.

task 'compile:js', 'compile js', ->
  yield exec 'coffee -bc app.coffee'

task 'minify:js',   'minify js', ->
  yield exec 'uglify-js --compress --mangle app.js > app.min.js'

This really pays dividends with more complicated tasks:

task 'package', 'Package project', ->
  yield exec '''
    mkdir -p dist
    rm   -rf dist/*
  '''

  yield exec.parallel '''
    cp manifest.json dist
    cp -rf assets    dist
    cp -rf lib       dist
    cp -rf views     dist
  '''

  yield exec '''
    zip -r package.zip dist
    rm -rf dist
  '''

Using Sake with Cake

You can upgrade any Cakefile into a Sakefile by requiring sake-core at the top of your Cakefile.

More

You can peruse Sake's Sakefile for a real world example.

License

BSD-3-Clause

sake-core's People

Contributors

greenkeeper[bot] avatar greenkeeperio-bot avatar zeekay avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sake-core's Issues

An in-range update of cake-bundle is breaking the build 🚨

Version 0.2.17 of cake-bundle just got published.

Branch Build failing 🚨
Dependency cake-bundle
Current Version 0.2.16
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

As cake-bundle is β€œonly” a devDependency of this project it might not break production or downstream projects, but β€œonly” your build or test tools – preventing new deploys or publishes.

I recommend you give this issue a high priority. I’m sure you can resolve this πŸ’ͺ


Status Details
  • ❌ continuous-integration/travis-ci/push The Travis CI build failed Details
Commits

The new version differs by 3 commits .

See the full diff.

Not sure how things should work exactly?

There is a collection of frequently asked questions and of course you may always ask my humans.


Your Greenkeeper Bot 🌴

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.