mirror of
https://github.com/DictXiong/dotfiles.git
synced 2025-04-24 21:46:52 +08:00
get.dotfiles.cn
This commit is contained in:
parent
b2e26067ac
commit
90e8efc0d9
17
.github/workflows/test.yml
vendored
17
.github/workflows/test.yml
vendored
|
@ -116,3 +116,20 @@ jobs:
|
|||
run: |
|
||||
echo $SHELL
|
||||
antigen list
|
||||
|
||||
test-get-dotfiles-cn:
|
||||
name: test of get.dotfiles.cn script
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: checkout repo
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: run the script
|
||||
run: |
|
||||
bash tools/get.dotfiles.cn
|
||||
|
||||
- name: run tests
|
||||
shell: /bin/zsh -ileo PIPE_FAIL {0}
|
||||
run: source tools/test.zsh
|
|
@ -1,4 +1,5 @@
|
|||
#!/bin/bash
|
||||
# ask_for_Yn is not compatible with `set -e`
|
||||
|
||||
THIS_DIR=$( cd "$( dirname "${BASH_SOURCE[0]:-${(%):-%x}}" )" && pwd )
|
||||
source "$THIS_DIR/tools/common.sh"
|
||||
|
@ -42,7 +43,7 @@ install_dependencies()
|
|||
"msys" )
|
||||
"$DOTFILES/tools/msys2.sh" pacman-S
|
||||
;;
|
||||
* ) fmt_error "dfs auto-install is not implemented on OS: $(get_os_name)"
|
||||
* ) fmt_error "dfs auto-install is not implemented on OS: $(get_os_name). skipping ..."
|
||||
esac
|
||||
}
|
||||
|
||||
|
|
50
tools/get.dotfiles.cn
Normal file
50
tools/get.dotfiles.cn
Normal file
|
@ -0,0 +1,50 @@
|
|||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
ARG=""
|
||||
GOT_OPTS=()
|
||||
while [[ $# > 0 || -n "$ARG" ]]; do
|
||||
if [[ -z "$ARG" ]]; then ARG=$1; shift; fi
|
||||
case $ARG in
|
||||
-s*|--secure ) DFS_SECURE=1 ;;
|
||||
-u*|--user )
|
||||
if [[ "$ARG" == --*=* ]]; then
|
||||
DFS_USER="${ARG#*=}"
|
||||
else
|
||||
DFS_USER=$1
|
||||
shift
|
||||
fi
|
||||
if [[ -z "$DFS_USER" ]]; then
|
||||
echo "install user is required"
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
--*=* ) GOT_OPTS+=("${ARG%%=*}" "${ARG#*=}") ;;
|
||||
--* ) GOT_OPTS+=("$ARG") ;;
|
||||
-* ) GOT_OPTS+=("${ARG:0:2}") ;;
|
||||
* ) GOT_OPTS+=("$ARG") ;;
|
||||
esac
|
||||
if [[ "$ARG" == "--"* || ! "$ARG" == "-"* || ${#ARG} -le 2 ]]; then
|
||||
ARG=""
|
||||
else
|
||||
ARG=-${ARG:2}
|
||||
fi
|
||||
done
|
||||
|
||||
# install
|
||||
if [[ -n "$DFS_USER" ]]; then
|
||||
su $DFS_USER
|
||||
fi
|
||||
cd
|
||||
if [[ ! -f ~/dotfiles/install.sh ]]; then
|
||||
git clone https://gitee.com/dictxiong/dotfiles
|
||||
fi
|
||||
if [[ "$DFS_SECURE" == "1" ]]; then
|
||||
echo "enter secure mode"
|
||||
cd dotfiles
|
||||
git fetch --all
|
||||
git -c advice.detachedHead=false checkout $(curl -fsSL https://api.beardic.cn/get-var/dfs-commit-id)
|
||||
cd
|
||||
fi
|
||||
./dotfiles/install.sh "${GOT_OPTS[@]}"
|
||||
zsh -c "source ~/.zshrc"
|
Loading…
Reference in New Issue
Block a user