Golang編寫的熱重載工具,自定義命令,支持監視文件及路徑配置,環境變量配置。這是一個重複的輪子~
地址在:github.com/yeqown/go-watcher,歡迎fork和PR。linux
go install github.com/yeqown/go-watcher/cmd/go-watcher
➜ go-watcher git:(master) ✗ ./go-watcher -h NAME: go-watcher - A new cli application USAGE: go-watcher [global options] command [command options] [arguments...] VERSION: 2.0.0 AUTHOR: yeqown@gmail.com COMMANDS: init generate a config file to specified position run execute a command, and watch the files, if any change to these files, the command will reload help, h Shows a list of commands or help for one command GLOBAL OPTIONS: --help, -h show help --version, -v print the version
watcher: # 監視器配置 duration: 2000 # 文件修改時間間隔,只有高於這個間隔纔回觸發重載 included_filetypes: # 監視的文件擴展類型 - .go # excluded_regexps: # 不被監視更改的文件正則表達式 - ^.gitignore$ - '*.yml$' - '*.txt$' additional_paths: [] # 除了當前文件夾須要額外監視的文件夾 excluded_paths: # 不須要監視的文件名,若爲相對路徑,只能對於當前路徑生效 - vendor - .git envs: # 額外的環境變量 - GOROOT=/path/to/your/goroot - GOPATH=/path/to/your/gopath
➜ go-watcher git:(master) ✗ ./package/osx/go-watcher run -e "make" -c ./config.yml [INFO] directory (/Users/yeqown/Projects/opensource/go-watcher) is under watching [INFO] directory (/Users/yeqown/Projects/opensource/go-watcher/cmd) is under watching [INFO] directory (/Users/yeqown/Projects/opensource/go-watcher/cmd/go-watcher) is under watching [INFO] directory (/Users/yeqown/Projects/opensource/go-watcher/internal) is under watching [INFO] directory (/Users/yeqown/Projects/opensource/go-watcher/internal/command) is under watching [INFO] directory (/Users/yeqown/Projects/opensource/go-watcher/internal/log) is under watching [INFO] directory (/Users/yeqown/Projects/opensource/go-watcher/internal/testdata) is under watching [INFO] directory (/Users/yeqown/Projects/opensource/go-watcher/internal/testdata/exclude) is under watching [INFO] directory (/Users/yeqown/Projects/opensource/go-watcher/internal/testdata/testdata_inner) is under watching [INFO] directory (/Users/yeqown/Projects/opensource/go-watcher/package) is under watching [INFO] directory (/Users/yeqown/Projects/opensource/go-watcher/package/archived) is under watching [INFO] directory (/Users/yeqown/Projects/opensource/go-watcher/package/linux) is under watching [INFO] directory (/Users/yeqown/Projects/opensource/go-watcher/package/osx) is under watching [INFO] directory (/Users/yeqown/Projects/opensource/go-watcher/resources) is under watching [INFO] directory (/Users/yeqown/Projects/opensource/go-watcher/utils) is under watching [INFO] directory (/Users/yeqown/Projects/opensource/go-watcher/utils/testdata) is under watching [INFO] directory (/Users/yeqown/Projects/opensource/go-watcher/utils/testdata/testdata_inner) is under watching rm -fr package go build -o package/osx/go-watcher cmd/go-watcher/main.go GOOS=linux GOARCH=amd64 go build -o package/linux/go-watcher cmd/go-watcher/main.go mkdir -p package/archived tar -zcvf package/archived/go-watcher.osx.tar.gz package/osx a package/osx a package/osx/go-watcher tar -zcvf package/archived/go-watcher.linux.tar.gz package/linux a package/linux a package/linux/go-watcher [INFO] command executed done! [INFO] (/Users/yeqown/Projects/opensource/go-watcher/package/osx/go-watcher) is skipped, not target filetype [INFO] (/Users/yeqown/Projects/opensource/go-watcher/package/osx) is skipped, not target filetype [INFO] (/Users/yeqown/Projects/opensource/go-watcher/package) is skipped, not target filetype [INFO] (/Users/yeqown/Projects/opensource/go-watcher/package/linux/go-watcher) is skipped, not target filetype [INFO] (/Users/yeqown/Projects/opensource/go-watcher/package/linux) is skipped, not target filetype [INFO] (/Users/yeqown/Projects/opensource/go-watcher/package/archived/go-watcher.linux.tar.gz) is skipped, not target filetype [INFO] (/Users/yeqown/Projects/opensource/go-watcher/package/archived) is skipped, not target filetype [INFO] (/Users/yeqown/Projects/opensource/go-watcher/VERSION) is skipped, not target filetype [INFO] [/Users/yeqown/Projects/opensource/go-watcher/cmd/go-watcher/main.go] changed rm -fr package mkdir -p package/osx mkdir -p package/linux echo "2.0.0" > VERSION cp VERSION package/osx cp VERSION package/linux go build -o package/osx/go-watcher cmd/go-watcher/main.go GOOS=linux GOARCH=amd64 go build -o package/linux/go-watcher cmd/go-watcher/main.go mkdir -p package/archived tar -zcvf package/archived/go-watcher.osx.tar.gz package/osx a package/osx a package/osx/go-watcher a package/osx/VERSION tar -zcvf package/archived/go-watcher.linux.tar.gz package/linux a package/linux a package/linux/go-watcher[INFO] (/Users/yeqown/Projects/opensource/go-watcher/package/osx) is skipped, not target filetype [INFO] (/Users/yeqown/Projects/opensource/go-watcher/package/linux) is skipped, not target filetype a package/linux/VERSION [INFO] command executed done! [INFO] (/Users/yeqown/Projects/opensource/go-watcher/package/osx) is skipped, not target filetype [INFO] (/Users/yeqown/Projects/opensource/go-watcher/package/archived) is skipped, not target filetype [INFO] (/Users/yeqown/Projects/opensource/go-watcher/package) is skipped, not target filetype [INFO] (/Users/yeqown/Projects/opensource/go-watcher/VERSION) is skipped, not target filetype [INFO] (/Users/yeqown/Projects/opensource/go-watcher/package) is skipped, not target filetype ^C[INFO] quit signal captured! [INFO] go-watcher exited ➜ go-watcher git:(master) ✗