foy 特点:使用: 介绍
福伊(foy) 是一个轻量级的基于 nodejs 和 promise 的通用 build 工具
特点:
-
类似于 shelljs 的跨平台 shell dsl, 人人都会写 shell
-
易学易用,无需为写仅仅几个build命令而花费几个小时去寻找和学习第三方包
-
很小的安装成本
使用:
安装
yarn add -D foy # or npm i -D foy # Or Install globally with yarn add -g foy # or npm i -g foy
在项目根目录下增加一个 Foyfile.js (或者 Foyfile.ts, 需要安装 ts-
node)
import { task, desc, option, strict, fs } from 'foy' task('build', async ctx => { await ctx.exec('tsc') }) 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('build2', async ctx => { await ctx.exec(`tsc ${ctx.options.watch ? '-w' : ''}`) }) task('task', async ctx => { await fs.rmrf('/some/dir/or/file') // Remove directory or file await fs.copy('/src', '/dist') // copy folder or file let json = await fs.readJson('./xx.json') await ctx.env('NODE_ENV', 'production') await ctx.cd('./src') await ctx.exec('some command') // Execute an command let { stdout } = await ctx.exec('ls', { stdio: 'pipe' }) // Get the stdout, default is empty because it's redirected to current process via `stdio: 'inherit'`. })
然后就可以运行任务了
# 安装在本地 node_modules 目录下 npx foy build npx foy build1 npx foy task # 安装在全局 foy build foy build1
foy 特点:使用: 官网
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。