Skip to content

Commit c25dc4f

Browse files
authored
[UPDATE] fix bashful update issue (#10)
1 parent ec88573 commit c25dc4f

File tree

7 files changed

+40
-18
lines changed

7 files changed

+40
-18
lines changed

.github/workflows/main.yml

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
name: CI Test
22

3-
on:
4-
push:
5-
branches:
6-
- master
3+
on: [push]
74

85
jobs:
96
build:

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
package-lock.json
22
test/results
3+
**/.DS_Store

bin/bashful

+36-12
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ manifest.listInstalledGists () {
2323
json "$__bash_suite_filesys/installation-manifest.json" '$.fromGists ? console.table($.fromGists) : console.log("\tNone")'
2424
echo;
2525
}
26-
manfiest.addGist () {
26+
manifest.addGist () {
2727
obj=`echo "{ \"name\": \"$1\", \"gistUrl\": \"$2\", \"revision\": $3 }"`
2828
data=$(json "$__bash_suite_filesys/installation-manifest.json" "
2929
// remove old references, and then add the new
@@ -33,19 +33,19 @@ manfiest.addGist () {
3333
")
3434
echo "$data" > "$__bash_suite_filesys/installation-manifest.json"
3535
}
36-
manfiest.getRegistryUrl () {
36+
manifest.getRegistryUrl () {
3737
json "$__bash_suite_filesys/installation-manifest.json" "
3838
console.log((\$).registries['$1'] || '')
3939
"
4040
}
41-
manfiest.removeGist () {
41+
manifest.removeGist () {
4242
data=$(json "$__bash_suite_filesys/installation-manifest.json" "
4343
\$.fromGists = \$.fromGists.filter(x => x.name !== '$1');
4444
console.log(JSON.stringify(\$))
4545
")
4646
echo "$data" > "$__bash_suite_filesys/installation-manifest.json"
4747
}
48-
manfiest.getGistUrl () {
48+
manifest.getGistUrl () {
4949
json "$__bash_suite_filesys/installation-manifest.json" "
5050
let [gist] = \$.fromGists.filter(x => x.name === '$1');
5151
if (gist) console.log(gist.gistUrl)
@@ -160,7 +160,7 @@ elif [ "$1" == "docs" ] || [ "$1" == "man" ]; then
160160
echo "Opening the BASHful Docs in your default browser"
161161
open "$__docs"
162162
else
163-
_url=$(manfiest.getGistUrl $2) # check for gist
163+
_url=$(manifest.getGistUrl $2) # check for gist
164164
if [ "$_url" == "" ]; then
165165
_url="$__docs/$2.html" # must be native
166166
fi
@@ -176,19 +176,43 @@ elif [ "$1" == "docs" ] || [ "$1" == "man" ]; then
176176
#: Running `bashful update` will also update `bashful`
177177
#:######################################################
178178
elif [ "$1" == "install" ] || [ "$1" == "update" ] ; then
179-
cd "$__SELF__";
180-
181179
if [ "$1" == "update" ]; then
180+
cd "$__TMP__";
181+
rm -rf bashful >/dev/null;
182182
echo Gathering latest files from GitHub
183-
git pull >/dev/null;
183+
git clone https://github.com/kyle-west/bashful;
184+
185+
# fail safe
186+
[ $? -eq 0 ] || ( echo "Failed to connect to https://github.com/kyle-west/bashful" && exit 1 )
187+
188+
rm -rf "$__SELF__"
189+
cp -a bashful "$__SELF__"
190+
191+
# copy RC and utils
192+
cp "$__SELF__/filesys/bashful.rc" "$__bash_suite_filesys/bashful.rc"
193+
cp -a "$__SELF__/filesys/utils" "$__bash_suite_filesys/utils"
194+
195+
# merge the registry files
196+
data=$(json "$__SELF__/filesys/registry.json" "
197+
let defaultRegistry = \$;
198+
let userRegistry = require('$__bash_suite_filesys/registry.json');
199+
Object.keys(\$.standard).forEach(package => {
200+
userRegistry.standard[package] = defaultRegistry.standard[package]
201+
})
202+
console.log(JSON.stringify(userRegistry))
203+
")
204+
echo "$data" > "$__bash_suite_filesys/registry.json"
205+
206+
source ~/.bashful.filesys/bashful.rc
184207
fi;
185208

209+
cd "$__SELF__";
186210
for program in "${@:2}"; do
187211
echo "Installing '$program'"
188212
if [ -f "bin/$program" ]; then
189213
cp "bin/$program" "$__bash_suite_program_dir/"
190214
else
191-
_url=$(manfiest.getGistUrl $program)
215+
_url=$(manifest.getGistUrl $program)
192216
if [ "$_url" != "" ]; then
193217
bashful gist install "$_url";
194218
else
@@ -212,7 +236,7 @@ elif [ "$1" == "uninstall" ]; then
212236
if [ "$program" != 'bashful' ]; then
213237
echo "Uninstalling '$program'"
214238
rm "$__bash_suite_program_dir/$program"
215-
manfiest.removeGist $program
239+
manifest.removeGist $program
216240
else
217241
echo "Cannot uninstall '$program'. Use 'bashful uninstall --remove-suite' if you mean to uninstall the entire BASHful Suite"
218242
fi
@@ -232,7 +256,7 @@ elif [ "$1" == "gist" ]; then
232256
if [ "$2" == "add" ]; then
233257
registry.addRegistryList $3
234258
elif [ "$2" == "update-registry" ]; then
235-
_url=`manfiest.getRegistryUrl $3`
259+
_url=`manifest.getRegistryUrl $3`
236260
registry.addRegistryList "$_url"
237261
elif [ "$2" == "info" ]; then
238262
registry.query $3
@@ -263,7 +287,7 @@ elif [ "$1" == "gist" ]; then
263287
echo;
264288
cd ../;
265289
rm -rf "$gist_hash";
266-
manfiest.addGist $file $_url `getGistVersion $_url`
290+
manifest.addGist $file $_url `getGistVersion $_url`
267291
fi
268292

269293
# bashful help

docs/favicon.png

2.12 KB
Loading

docs/logo.png

2 KB
Loading

filesys/bashful.rc

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ export PATH="${PATH}:$(echo ~/.bashful)"
99
alias bashful.parseArgs="source ~/.bashful.filesys/utils/parse-args"
1010
bashful.autoDocs () {
1111
grep "^#:" "$1" | sed -e 's/#://g' -e 's/#//g'
12-
}
12+
}

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "bashful",
3-
"version": "3.1.1",
3+
"version": "3.1.2",
44
"description": "Install my custom suite of terminal tools for Bash in OSX",
55
"main": "install.sh",
66
"scripts": {

0 commit comments

Comments
 (0)