A simple, light-weight and modern task runner for general purpose.
- Promise-based tasks and built-in utilities.
- shelljs like commands
- Easy to learn, stop spending hours for build tools.
- Small install size
yarn add -D foy # or npm i -D foy
Or Install globally with
yarn add -g foy # or npm i -g foy
Write a Foyfile
You need to add a Foyfile.js(or Foyfile.ts with ts-node installed) in your project root.
Also, you can simply generate a Foyfile.js via:
Then it will put a simple
Foyfile.js in current folder:
// Foyfile.jsconst task =
You can also generate a
foy --init ts
Then we can run
foy build to execute the
You can also add some options and description to task:
desc'Build ts files with tsc'option'-w, --watch', 'watch file changes'strict // This will throw an error if you passed some options that doesn't defined via `option()`task'build',
foy build -w
Using with built-in promised-based API
Using with other packages
task'test',task'build',task'publish:patch',, // Run test and build before publish
Or, you can pass options to customize the execution of dependences:
task'publish:patch',,/* Sugar version */task'publish:patch',,/*Priority for async tasksDefault is 0, bigger is formmer, then we will run `build` before `test`.If you have multi async dependencies with same priority, they will be executed parallel.*/task'publish:patch',,
You can also pass options to dependences:
task'task1',task'task2',// foy task2 -a 1
If you have lots of tasks, naming might be a problem, what foy do is to making life easier, but more anxious. So we provide a
namespacify function to generate task names with namespaces.
// namespacify(names: object, ns = '', sep = ':')namespacens.client,namespacens.server,taskns.start, // start// foy start// foy client:build
Using in CI servers
If you use Foy in CI servers, you might won't want the loading because most CI servers will log the stdout and stderr to files, the loading will be logged as frames. Luckily, Foy has already considered this use case, you can simple disable the loading behavior like this:
setGlobalOptions // disable loading animationstask'test',/*$ foy testDependencyGraph for task [test]:─ testTask: test...*/
Using lifecycle hooks
You can use before/after/onerror to do something in lifecycles.
Watch and build
Using with custom compiler
# Write Foyfile in ts, enabled by defaultfoy -r ts-node/register -c ./some/Foyfile.ts build# Write Foyfile in coffeefoy -r coffeescript/register -c ./some/Foyfile.coffee build