轻量级的项目 build 工具 foy

码农软件 · 软件分类 · Node.js 扩展 · 2019-04-13 21:57:31

软件介绍

福伊(foy) 是一个轻量级的基于 nodejs 和 promise 的通用 build 工具

特点:

  • 基于 promise 的任务和内置工具函数(fs/shell), 无缝支持 async/await

  • 类似于 shelljs 的跨平台 shell dsl, 人人都会写 shell

  • 易学易用,无需为写仅仅几个build命令而花费几个小时去寻找和学习第三方包

  • 很小的安装成本

    • foy: 831KB

    • gulp:4.82MB 

    • grunt:4.19MB 

  •    无缝和第三方支持 promise 的工具包整合,不需要封装成插件就能用

使用:

安装

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

本文地址:https://codercto.com/soft/d/3524.html

深入浅出程序设计(中文版)

深入浅出程序设计(中文版)

Paul Barry、David Griffiths / 蒋雁翔、童健 / 东南大学出版社 / 2012-1 / 98.00元

《深入浅出程序设计(中文版)》介绍了编写计算机程序的核心概念:变量、判断、循环、函数与对象——无论运用哪种编程语言,都能在动态且多用途的python语言中使用具体示例和练习来运用并巩固这些概念。学习基本的工具来开始编写你感兴趣的程序,而不是其他人认为你应该使用的通用软件,并对软件能做什么(不能做什么)有一个更好的了解。当你完成这些,你就拥有了必要的基础去使用任何一种你需要或想要学习的语言或软件项目......一起来看看 《深入浅出程序设计(中文版)》 这本书的介绍吧!

XML 在线格式化
XML 在线格式化

在线 XML 格式化压缩工具

html转js在线工具
html转js在线工具

html转js在线工具

HSV CMYK 转换工具
HSV CMYK 转换工具

HSV CMYK互换工具