forked from canonical/dbus.dart
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dev_install
executable file
·60 lines (42 loc) · 1.33 KB
/
dev_install
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
#!/bin/bash
set -e
# Check arguments
if [ "$1" != "install" ] && [ "$1" != "remove" ]; then
echo "Usage: $0 install | remove"
exit 1;
fi
DIR=$(cd `dirname $0` && pwd)
cd $DIR/
# Determine install path from pubspec
input="./pubspec.yaml"
mapfile -s 0 name < $input
mapfile -s 1 version < $input
name=$(echo $name | cut -d' ' -f 2)
version=$(echo $version | cut -d' ' -f 2)
package=$(echo $HOME/.pub-cache/hosted/pub.dartlang.org/$name-$version)
# Install
if [ "$1" == "install" ]; then
# If symlink does not already exist
if ! [[ -L "$package" && -d "$package" ]]; then
# Backup if needed
if [ -d "$package" ]; then mv $package $package-backup; fi
# Create symlink
ln -s $DIR $package
echo "Local" $name-$version "installed."
echo "Changes to this project will now automatically reflect in its dependants."
else
echo "Local" $name-$version "already installed."
fi
# Remove
elif [ "$1" == "remove" ]; then
# If symlink exists
if [[ -L "$package" && -d "$package" ]]; then
# Remove symlink
rm $package
# Restore backup if present
if [ -d "$package-backup" ]; then mv $package-backup $package; fi
echo "Local" $name-$version "uninstalled."
else
echo "Local" $name-$version "already uninstalled."
fi
fi