This repository has been archived by the owner on Sep 14, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.coffee
62 lines (47 loc) · 1.59 KB
/
gulpfile.coffee
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
'use strict'
gulp = require('gulp')
del = require('del')
path = require('path')
child_process = require('child_process')
homePath = require('home-path')()
$ = require('gulp-load-plugins')()
repoPath = 'rxrc/zshrc'
branchInitial = 'master'
branch = "#{child_process.execSync('git rev-parse --abbrev-ref HEAD')}".trim()
pluginPath = "#{homePath}/.zgen/local/zshrc-#{branch}"
zgenReset = -> del("#{homePath}/.zgen/init.zsh", {force: true})
gulp.task 'default', ['watch']
gulp.task 'dev', ['clean', 'replace', 'install']
gulp.task 'nodev', ['clean'], ->
gulp.src("#{homePath}/.zshrc")
.pipe $.replace("branch='#{branch}'", "branch='#{branchInitial}'")
.pipe gulp.dest(homePath)
gulp.task 'clean', ->
del(pluginPath, {force: true})
zgenReset()
gulp.task 'replace', ->
gulp.src("#{homePath}/.zshrc")
.pipe $.replace("branch='#{branchInitial}'", "branch='#{branch}'")
.pipe gulp.dest(homePath)
gulp.task 'install', ->
gulp.src('*.zsh')
.pipe gulp.dest(pluginPath)
gulp.src('plugin/**/*.zsh')
.pipe gulp.dest("#{pluginPath}/plugin")
gulp.src('plugins.zsh')
.pipe $.replace(
"zgen load #{repoPath} plugin"
"zgen load #{process.cwd()} plugin #{branch}")
.pipe gulp.dest(pluginPath)
gulp.task 'watch', ['install'], ->
$.watch ['./*.zsh', './plugin/**/*.zsh'], (file) ->
if file.event is 'add'
zgenReset()
if file.event is 'unlink'
del(file.path, {force: true})
zgenReset()
if file.relative is 'plugins.zsh' then zgenReset()
.pipe $.replace(
"zgen load #{repoPath} plugin"
"zgen load #{process.cwd()} plugin #{branch}")
.pipe gulp.dest(pluginPath)