Git Product home page Git Product logo

flow-watch's Introduction

flow-watch

A simple file watcher that clears the console and runs flow on each change. Currently tested on OS X -- I don't know if it works on Linux or Windows. Works with flow on your path or flow-bin installed as a peer dependency.

Usage

npm install --save-dev flow-watch

Then run the flow-watch command.

flow-watch passes known nodemon options to nodemon, and all other options to flow.

You may not need this?

nodemon has a documented way to clear the console on restart, so you may want to use nodemon/flow directly in a package script instead of using flow-watch.

To use nodemon and flow, you can add this to your package.json (tested with [email protected]):

{
  "scripts": {
    "flow:watch": "nodemon -x 'flow || exit 1'"
  },
  "nodemonConfig": {
    "events": {
      "start": "cls || clear"
    }
  }
}

Configuration

flow-watch uses nodemon and accepts any command-line options that nodemon does. If you provide no arguments, it uses the following defaults:

--ignore node_modules/ --watch *.js --watch *.jsx --watch *.js.flow --watch .flowconfig

By default, the watcher will clear the console between each change. If you wish to override this behavior, use the FLOW_WATCH_NO_CLEAR_CONSOLE env variable. If you choose that approach, you may also want to silent the [nodemon] messages in the console, which you can do with the --quiet flag (or -q). Putting it all together:

{
  "scripts": {
    "flow:watch": "FLOW_WATCH_NO_CLEAR_CONSOLE=1 flow-watch -q"
  }
}

flow-watch's People

Contributors

acusti avatar greenkeeper[bot] avatar jedwards1211 avatar maka-io avatar sorahn 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

Watchers

 avatar  avatar  avatar

flow-watch's Issues

Babel compatibility?

vanilla Flow works well with Babel (when used with no arguments). But flow-watch (on Ubuntu Linux 16.04.1, Node v8.x) appears to to bypass Babel. Am I flow-watching wrong?

Seems to work in Linux

Hi, just a small heads-up to say it's working for me in Linux. If I encounter any problems I can post them in this issue if you want.

Best,
Maarten

Thanks for the note on Nodemon

I've been using nodemon for a ton over the years, so I was glad when I saw you refer to it. Since it might not be clear how to set it up, I thought I'd share my approach in case anyone would prefer it:

In package.json:

"scripts": {
  "flow": "nodemon --exec ./flow-clean-exit.sh"
}

Create ./flow-clean-exit.sh (In the root of your project):

#!/bin/bash

clear # Clear the terminal

# Trap, so `nodemon` will continue to work when flow encounters an error
# Otherwise, `flow` changes the process exit code and `nodemon` crashes
trap './node_modules/.bin/flow' EXIT

Run chmod +x ./flow-clean-exit.sh to give it permission to run.

And you're done.

npm run flow and you'll launch this service that'll watch for changes and rerun flow.

passing arguments to flow

Hi, thanks for the great work!

Is it possible to pass arguments to flow binary?
Would be nice to be able to pass options such as --show-all-errors

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.