Jake: javascript 里的 make 工具

一个前端圈里的,任务管理工具
更新于: 2023-03-09 19:27:30

大纲

  • 安装
  • 配置文件
  • 快速开始
  • 基本 api

安装

# 全局安装
yarn global add jake
npm install --location=global jake

# 安装到项目中
yarn add -D jake

配置文件

优先识别: Jakefile, Jakefile.js, jakefile, or jakefile.js

快速开始

# 创建配置文件,文件内容如下
touch Jakefile
# 列出所有task
jake -T
# 执行默认
jake
# 执行 otherTask
jake otherTask
let { task, desc } = require('jake');

desc('This is the default task.');
task('default', function () {
  console.log('This is the default task.');
  console.log('Jake will run this task if you run `jake` with no task specified.');
});

desc('This is some other task. It depends on the default task');
task('otherTask', ['default'], function () {
  console.log('Some other task');
});

基本api

-f / --jakefile FILEUse FILE as the Jakefile.
-C / --directory DIRECTORYChange to DIRECTORY before running tasks.
-q / --quietDo not log built-in Jake messages to standard output.
-B / --always-makeUnconditionally make all targets.
-t / -T / -ls / --tasks [PATTERN]Display the tasks (matching optional PATTERN) with descriptions, then exit.
-J / --jakelibdir JAKELIBDIRAuto-import any .jake files in JAKELIBDIR (default is 'jakelib').
-h / --helpDisplay this help message.
-V / -v / --versionDisplay the Jake version.

参考