Skip to content

Commit

Permalink
Add open_link script to allow us open a link in all platforms from Ma…
Browse files Browse the repository at this point in the history
…kefile or any script
  • Loading branch information
imaNNeo committed Mar 23, 2022
1 parent 846c40e commit fd3a8b6
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ codeGen:
showTestCoverage:
@flutter test --coverage
@genhtml coverage/lcov.info -o coverage/html
@google-chrome coverage/html/index.html
$(shell . ./scripts/makefile_scripts.sh; open_link "coverage/html/index.html")
27 changes: 27 additions & 0 deletions scripts/makefile_scripts.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash

# Opens a link with the default browser of OS (It works cross-platform)
#
## You can call it like `open_link balad.ir` to open balad website on your default browser
open_link () {
case "$(uname -s)" in
Darwin)
# macOS
open "$1"
;;

Linux)
# Linux:
xdg-open "$1"
;;

CYGWIN*|MINGW32*|MSYS*|MINGW*)
# Windows
start "$1"
;;

*)
echo 'Not supported OS'
;;
esac
}

0 comments on commit fd3a8b6

Please sign in to comment.