Skip to content

Commit 670613a

Browse files
committed
Add global .gitignore prompt to the installer
1 parent 98de74e commit 670613a

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Clone this repository into your Magento folder. Remember not to commit it.
3131

3232
You can also do this, athough you shouldn't. It will install it under `./script_runner`.
3333
```shell script
34-
sh -c "$(curl -SsfL https://raw.githubusercontent.com/marcusirgens/magento2-script-runner/main/install.sh)"
34+
bash -c "$(curl -SsfL https://raw.githubusercontent.com/marcusirgens/magento2-script-runner/main/install.sh)"
3535
```
3636

3737
If you're in your Magento 2 application directory at `/my/code/folder`,

install.sh

+21-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,25 @@
1-
#!/bin/sh
1+
#!/bin/bash
2+
# Simple installer for the script runner
23

3-
set -eux
4+
# https://www.davidpashley.com/articles/writing-robust-shell-scripts/
5+
set -eu
46

7+
# Clone and remove git directory
8+
# https://stackoverflow.com/a/11498124/9738360
59
git clone --depth=1 --branch=main git@github.com:marcusirgens/magento2-script-runner.git ./script_runner
610
rm -rf ./script_runner/.git
11+
12+
# Get the global gitignore
13+
global_ignore="$(git config --global --get core.excludesfile)"
14+
15+
# If that file does not exist, don't do anything.
16+
if [ -n "$global_ignore" ]; then
17+
if ! grep -Eq '^script_runner.*' "$global_ignore"; then
18+
# https://stackoverflow.com/questions/1885525/how-do-i-prompt-a-user-for-confirmation-in-bash-script
19+
read -p "Do you want to add script_runner/* to your global .gitignore file? [y/n]" -n 1 -r
20+
echo # (optional) move to a new line
21+
if [[ $REPLY =~ ^[Yy]$ ]]; then
22+
echo "script_runner/*" >> "$global_ignore"
23+
fi
24+
fi
25+
fi

0 commit comments

Comments
 (0)