0a80889848ccb3ada94dd2fdb793a01a268f7a16

Author
Will Mendes <willmendesneto@gmail.com>
Committer
Will Mendes <willmendesneto@gmail.com>
Date

Message

Frontend-search: add search in npm website

Diff

 1diff --git a/plugins/frontend-search/README.md b/plugins/frontend-search/README.md
 2index 801d450f300db76af79370ce96f2ac9ef65ba024..b8e96ea4a36770a7731b4c20e30221a43594bc7a 100644
 3--- a/plugins/frontend-search/README.md
 4+++ b/plugins/frontend-search/README.md
 5@@ -43,6 +43,7 @@ The search content are
 6 * `reactjs <google.com/search?as_q=<search-term>&as_sitesearch=facebook.github.io/react>`
 7 * `emberjs <emberjs.com>`
 8 * `stackoverflow <stackoverflow.com>`
 9+* `npmjs <npmjs.com>`
10 
11 
12 ## Aliases ##
13@@ -69,6 +70,7 @@ There are a few aliases presented as well:
14 * `reactjs` A shorthand for `frontend reactjs`
15 * `emberjs` A shorthand for `frontend emberjs`
16 * `stackoverflow` A shorthand for `frontend stackoverflow`
17+* `npmjs` A shorthand for `frontend npmjs`
18 
19 
20 ## Author
21diff --git a/plugins/frontend-search/_frontend-search.sh b/plugins/frontend-search/_frontend-search.sh
22index 252f215707240ce8c11236d919b601c51791be62..b12f829a1c58e52388c7a613b9569ec7406ce3cf 100644
23--- a/plugins/frontend-search/_frontend-search.sh
24+++ b/plugins/frontend-search/_frontend-search.sh
25@@ -37,6 +37,7 @@ function _frontend() {
26     'reactjs: Search in React website'
27     'emberjs: Search in Ember website'
28     'stackoverflow: Search in StackOverflow website'
29+    'npmjs: Search in NPMJS website'
30   )
31 
32   _arguments -C \
33@@ -110,6 +111,9 @@ function _frontend() {
34         stackoverflow)
35           _describe -t points "Warp points" frontend_points && ret=0
36           ;;
37+        npmjs)
38+          _describe -t points "Warp points" frontend_points && ret=0
39+          ;;
40       esac
41       ;;
42   esac
43diff --git a/plugins/frontend-search/frontend-search.plugin.zsh b/plugins/frontend-search/frontend-search.plugin.zsh
44index f7485621bf444e479a6bd23e37eef220d733d317..e47735a60fe7fc2ea455f4e95ee236df8f4f24de 100644
45--- a/plugins/frontend-search/frontend-search.plugin.zsh
46+++ b/plugins/frontend-search/frontend-search.plugin.zsh
47@@ -9,7 +9,7 @@ function frontend() {
48   fi
49 
50   # check whether the search engine is supported
51-  if [[ ! $1 =~ '(jquery|mdn|compass|html5please|caniuse|aurajs|dartlang|qunit|fontello|bootsnipp|cssflow|codepen|unheap|bem|smacss|angularjs|reactjs|emberjs|stackoverflow)' ]];
52+  if [[ ! $1 =~ '(jquery|mdn|compass|html5please|caniuse|aurajs|dartlang|qunit|fontello|bootsnipp|cssflow|codepen|unheap|bem|smacss|angularjs|reactjs|emberjs|stackoverflow|npmjs)' ]];
53   then
54     echo "Search valid search content $1 not supported."
55     echo "Valid contents: (formats 'frontend <search-content>' or '<search-content>')"
56@@ -33,6 +33,7 @@ function frontend() {
57     echo "* reactjs"
58     echo "* emberjs"
59     echo "* stackoverflow"
60+    echo "* npmjs"
61     echo ""
62 
63     return 1
64@@ -99,6 +100,9 @@ function frontend() {
65     "stackoverflow")
66       url="${url}stackoverflow.com"
67       url="${url}/search?q=$2" ;;
68+    "npmjs")
69+      url="${url}www.npmjs.com"
70+      url="${url}/search?q=$2" ;;
71     *) echo "INVALID PARAM!"
72        return ;;
73   esac
74@@ -148,3 +152,4 @@ alias emberjs='frontend emberjs'
75 
76 # search websites
77 alias stackoverflow='frontend stackoverflow'
78+alias npmjs='frontend npmjs'