lila-tasks
v2.0.2
Published
lila built-in tasks
Maintainers
Readme
lila-tasks
lila 内置的 tasks
安装
npm install --save-dev lila-tasks使用
在 lila.init.js 中:
import tasksPlugin from 'lila-tasks';
export default lila => {
tasksPlugin(lila);
...
};内置任务
@lila/make: 创建文件(相对于 root)
['@lila/make', {file, content, force}]}]file:type: string要操作的文件.content:type: string文件内容.force:type: booldefault: false如果文件已存在,是否覆盖.
@lila/replace: 替换文件内容(相对于 root)
['@lila/replace', {file, replace: [{target, replacement}]}]file:type: string要操作的文件.replace:type: []替换选项.target:type: string|RegExp需要被替换的文本.replacement:type: string替换的文本.
@lila/insert: 插入文件内容(相对于 root)
['@lila/insert', {file, start, end}]file:type: string要操作的文件.start:type: string插入在文件最前面的内容.end:type: string插入在文件最后面的内容.
@lila/convert: 更改文件的扩展名(相对于 root)
['@lila/convert', {file, ext}]file:type: string要操作的文件.ext:type: string扩展名, 如php, jsp.
@lila/backup: 备份文件(相对于 root)
复制文件并添加后缀, index.html -> index.2000-01-02-03-04-05.html.
['@lila/backup', {file, suffix}]file:type: string要操作的文件.suffix:type: stringdefault: (new Date()).getTime()index.html -> index.${suffix}.html.
@lila/move: 移动文件或目录(相对于 root)
['@lila/move', {source, target, force}]source:type: string源文件或目录target:type: string目标文件或目录force:type: booldefault: false如果目录已存在,是否覆盖
@lila/copy: 复制文件或目录(相对于 root)
['@lila/copy', {source, target, force}]source:type: string源文件或目录target:type: string目标文件或目录force:type: booldefault: false如果目录已存在,是否覆盖
@lila/del: 删除文件或目录(相对于 root)
['@lila/del', file]
['@lila/del', dir]
['@lila/del', [file1, dir2, dir3, ...]]@lila/del-dev: 删除 dev 目录
'@lila/del-dev'@lila/del-build: 删除 build 目录
'@lila/del-build'@lila/del-tmp: 删除 tmp 目录
'@lila/del-tmp'@lila/sync: 同步文件到远程服务器
['@lila/sync', {src, server, remotePath}]src:globs/[globs, options]gulp.srcserver:type: {}服务器配置, 查看 gulp-ssh.remotePath:type: string要上传的远程服务器路径.cache:type: booleandefault: false是否缓存已上传的文件.cacheFileName:type: stringdefault: cache缓存记录生成的文件名.
@lila/sync-save-cache: 运行 @lila/sync 任务后保存操作文件的记录
['@lila/sync-save-cache', {cacheFileName}]cacheFileName:type: stringdefault: cache缓存记录生成的文件名.
@lila/sync-dir: 同步目录到远程服务器(相对于 root)
['@lila/sync-dir', {server, remotePath, dirs}]server:type: {}服务器配置, 查看 gulp-ssh.remotePath:type: string要上传的远程服务器路径.dirs:type: string/array要上传的目录.
@lila/sync-build: 同步 build 目录到远程服务器(相对于 root)
['@lila/sync-build', {server, remotePath, sourceMap}]server:type: {}服务器配置, 查看 gulp-ssh.remotePath:type: string要上传的远程服务器路径.sourceMap:type: booldefault: true是否上传 source-map 文件.
@lila/sync-html: 同步 html 文件到远程服务器(相对于 build)
['@lila/sync-html', {server, remotePath, ext}]server:type: {}服务器配置, 查看 gulp-ssh.remotePath:type: string要上传的远程服务器路径.ext:type: stringdefault: htmlhtml 文件扩展名.
@lila/sync-source-map: 同步 source-map 文件到远程服务器(相对于 build)
['@lila/sync-source-map', {server, remotePath}]server:type: {}服务器配置, 查看 gulp-ssh.remotePath:type: string要上传的远程服务器路径.
@lila/clean-cache: 移除上次操作过的文件,保留未操作过的文件,主要用于记录 build 目录
'@lila/clean-cache'
// or
['@lila/clean-cache', {dir, cacheFileName}]dir:type: string待操作的目录(相对于root)cacheFileName:type: stringdefault: cache缓存记录生成的文件名.
@lila/save-cache: 保存文件到操作记录中, 主要用于记录 build 目录
'@lila/save-cache'
// or
['@lila/save-cache', {dir, cacheFileName}]dir:type: string待操作的目录(相对于root)cacheFileName:type: stringdefault: cache缓存记录生成的文件名.
@lila/shell: 执行 shell 脚本
['@lila/shell', {command, args, options}]command, args, options: 查看 child_process spawn
@lila/ssh-exec: 在远程服务器执行命令
可用版本 >= v1.0.1
['@lila/ssh-exec', {server, script}]server:type: {}服务器配置, 查看 ssh2 connect.script:type: string需要在远程服务器执行的命令,多个命令可使用&&连接.
@lila/remote-exec: 在远程服务器执行命令
可用版本 >= v1.0.1
['@lila/remote-exec', {server, scripts, log}]server:type: {}服务器配置, 查看 gulp-ssh exec.scripts:type: string/array需要在远程服务器执行的命令.log:type: stringdefault: remote-exec.log日志文件.
@lila/remote-shell: 在远程服务器执行 shell 脚本
!!!某些命令可能会导致连接挂起不结束,请使用@lila/ssh-exec或@lila/remote-exec代替
['@lila/remote-shell', {server, scripts, log}]server:type: {}服务器配置, 查看 gulp-ssh shell.scripts:type: string/array需要在远程服务器执行的 shell 脚本.log:type: stringdefault: remote-shell.log日志文件.
