1
1
#! /bin/bash
2
2
3
- Apm_modules_file_name =" Ashmodules"
4
- Apm_modules_clone_directory =" .ash_modules_tmp"
5
- Apm_modules_file_path =" $Ash__call_directory /$Apm_modules_file_name "
6
- Apm_local_modules_directory_path =" $Ash__call_directory /$Ash__modules_foldername "
7
- Apm_local_modules_clone_path =" $Ash__call_directory /$Apm_modules_clone_directory "
3
+ Apm_MODULES_FILE_NAME =" Ashmodules"
4
+ Apm_MODULES_CLONE_DIRECTORY =" .ash_modules_tmp"
5
+ Apm_MODULES_FILE_PATH =" $Ash__call_directory /$Apm_MODULES_FILE_NAME "
6
+ Apm_LOCAL_MODULES_DIRECTORY_PATH =" $Ash__call_directory /$Ash__modules_foldername "
7
+ Apm_LOCAL_MODULES_CLONE_PATH =" $Ash__call_directory /$Apm_MODULES_CLONE_DIRECTORY "
8
8
9
9
# #################################################
10
10
# This function is an alias for `ash self:help`.
@@ -27,8 +27,8 @@ Apm__callable_help() {
27
27
# #################################################
28
28
Apm__callable_init () {
29
29
# Hasn't been created
30
- if [[ ! -f " $Apm_modules_file_path " ]]; then
31
- touch " $Apm_modules_file_path "
30
+ if [[ ! -f " $Apm_MODULES_FILE_PATH " ]]; then
31
+ touch " $Apm_MODULES_FILE_PATH "
32
32
Logger__success " Directory successfully initialized"
33
33
34
34
# Has already been created
@@ -50,9 +50,9 @@ Apm__callable_init() {
50
50
# #################################################
51
51
Apm__callable_install () {
52
52
# Creating modules directory
53
- if [[ " $2 " != " --global" && ! -d " $Apm_local_modules_directory_path " ]]; then
54
- mkdir " $Apm_local_modules_directory_path "
55
- touch " $Apm_local_modules_directory_path /$Ash_module_aliases_file "
53
+ if [[ " $2 " != " --global" && ! -d " $Apm_LOCAL_MODULES_DIRECTORY_PATH " ]]; then
54
+ mkdir " $Apm_LOCAL_MODULES_DIRECTORY_PATH "
55
+ touch " $Apm_LOCAL_MODULES_DIRECTORY_PATH /$Ash_module_aliases_file "
56
56
fi
57
57
58
58
# If user is passing in URL
@@ -81,9 +81,9 @@ Apm__callable_modules() {
81
81
# This function will update a global module or
82
82
# Ash itself.
83
83
#
84
- # @param $1: The global module's `name` as defined
85
- # in it's ash_config.yaml file. To update Ash
86
- # itself, simply just pass `ash` here.
84
+ # @param $1: The alias or package of a global
85
+ # module. To update Ash itself, simply just pass
86
+ # `ash` here.
87
87
# #################################################
88
88
Apm__callable_update (){
89
89
local module_name=" $1 "
@@ -94,52 +94,11 @@ Apm__callable_update(){
94
94
return
95
95
fi
96
96
97
- # Checking if we're updating ash
97
+ # Update
98
98
if [[ " $module_name " = ' ash' ]]; then
99
- cd $Ash__source_directory
100
-
101
- # Updating
102
- git pull origin master
103
- git submodule update
104
-
105
- # Checking for success
106
- if [ $? -eq 0 ]; then
107
- Logger__success " Ash was updated"
108
- else
109
- Logger__error " Something went wrong, Ash was not updated"
110
- Logger__error " You will have to manually update at $Ash__source_directory "
111
- fi
112
-
99
+ Apm_update_ash
113
100
return
114
- fi
115
-
116
- # Expanding alias
117
- local alias_file=" $Ash__source_directory /$Ash_global_modules_directory /$Ash_module_aliases_file "
118
- local has_key=$( YamlParse__has_key " $alias_file " " $module_name " )
119
- if [[ " $has_key " == $Ash__true ]]; then
120
- eval $( YamlParse__parse " $alias_file " " Apm_update_" )
121
- local variable=" Apm_update_$module_name "
122
- module_name=${! variable}
123
- fi
124
-
125
- # Checking if we're passing a valid global module
126
- local directory=" $Ash__source_directory /$Ash_global_modules_directory /$module_name "
127
- local directory_config=" $directory /$Ash_config_filename "
128
- if [[ -f " $directory_config " ]]; then
129
- Logger__log " Updating $module_name "
130
-
131
- # Updating
132
- cd " $directory "
133
- git pull origin master
134
-
135
- # Checking for success
136
- if [ $? -eq 0 ]; then
137
- Logger__success " $module_name was updated"
138
- else
139
- Logger__error " Something went wrong, $module_name was not updated"
140
- Logger__error " You will have to manually update at $directory "
141
- fi
142
101
else
143
- Logger__error " Module \" $module_name \" does not exist "
102
+ Apm_update_module " $module_name "
144
103
fi
145
104
}
0 commit comments