-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from Avivbens/change-defaults
change defaults
- Loading branch information
Showing
5 changed files
with
17 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,11 @@ | ||
#!/usr/bin/env bash | ||
|
||
if [[ -z "$alfred_workflow_cache" ]]; then | ||
echo "This script must be called from Alfred, \$alfred_workflow_cache is missing. Make sure a Bundle ID is set." | ||
exit 1 | ||
fi | ||
|
||
if [[ ! -d "$alfred_workflow_cache" ]]; then | ||
mkdir -p "$alfred_workflow_cache" | ||
fi | ||
|
||
PATH_CACHE="$alfred_workflow_cache"/node_path | ||
|
||
get_user_path() { | ||
eval $(/usr/libexec/path_helper -s) | ||
echo "$($SHELL -i -l -c 'echo -e "\n"PATH=\"$PATH:\$PATH\""\n"' 2>/dev/null | grep "^PATH=")" > "$PATH_CACHE" | ||
function has_node() { | ||
command -v node >/dev/null 2>&1 | ||
} | ||
|
||
set_path() { | ||
if [[ -f "$PATH_CACHE" ]]; then | ||
. "$PATH_CACHE" | ||
else | ||
get_user_path | ||
. "$PATH_CACHE" | ||
fi | ||
|
||
export PATH | ||
} | ||
|
||
has_node() { | ||
command -v node >/dev/null 2>&1 | ||
} | ||
|
||
# Check if we have Node.js, otherwise inherit path from user shell | ||
if ! has_node; then | ||
set_path | ||
|
||
# Retry by deleting old path cache | ||
if ! has_node; then | ||
rm "$PATH_CACHE" | ||
set_path | ||
fi | ||
fi | ||
|
||
if has_node; then | ||
node "$@" | ||
node "$@" | ||
else | ||
echo $'{"items":[{"title": "Couldn\'t find the `node` binary", "subtitle": "Symlink it to `/usr/local/bin`"}]}' | ||
echo $'{"items":[{"title": "Couldn\'t find the `node` binary", "subtitle": "Make sure Node.js installed (HomeBrew recommended)", "icon": {"path": "/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/AlertStopIcon.icns"}}]}' | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters