@@ -154,7 +154,7 @@ npm_install() {
154154 fi
155155 npm install " ${pkg_name} @${pkg_version} "
156156 if [[ " $? " -ne 0 ]]; then
157- echo " Installation of package ${pkg_name} @${pkg_version} via npm failed ." >&2
157+ echo " Encountered an error when installing ${pkg_name} @${pkg_version} via npm." >&2
158158 return 1
159159 fi
160160 install_test
@@ -179,7 +179,7 @@ npm_install_from_github() {
179179 fi
180180 npm install " ${pkg_github_url} #${pkg_github_tag} "
181181 if [[ " $? " -ne 0 ]]; then
182- echo " Installation of package ${pkg_github_url} #${pkg_github_tag} via npm failed ." >&2
182+ echo " Encountered an error when installing ${pkg_github_url} #${pkg_github_tag} via npm." >&2
183183 return 1
184184 fi
185185 install_test
@@ -195,6 +195,26 @@ npm_install_from_github() {
195195 return 0
196196}
197197
198+ # Installs a package globally via `npm`.
199+ npm_install_global () {
200+ npm install -g " ${pkg_name} @${pkg_version} "
201+ if [[ " $? " -ne 0 ]]; then
202+ echo " Encountered an error when installing ${pkg_name} @${pkg_version} as a global package via npm." >&2
203+ return 1
204+ fi
205+ stdlib --help
206+ if [[ " $? " -ne 0 ]]; then
207+ echo " Encountered an error when testing installation." >&2
208+ return 1
209+ fi
210+ npm uninstall -g " ${pkg_name} @${pkg_version} "
211+ if [[ " $? " -ne 0 ]]; then
212+ echo " Encountered an error when performing post-install cleanup tasks." >&2
213+ return 1
214+ fi
215+ return 0
216+ }
217+
198218# Tests whether the project successfully installs via `npm`.
199219#
200220# $1 - log file
@@ -229,6 +249,21 @@ test_npm_install() {
229249 fi
230250 echo ' Successfully installed (via GitHub).' >&2
231251
252+ echo ' Testing npm install (global)...' >&2
253+ npm_install_global >> " $1 " 2>&1
254+ if [[ " $? " -ne 0 ]]; then
255+ echo ' Installation (global) failed.' >&2
256+ echo ' Retry 1 of 1...' >&2
257+ sleep 15s
258+ echo ' Testing npm install (global)...' >&2
259+ npm_install_global >> " $1 " 2>&1
260+ if [[ " $? " -ne 0 ]]; then
261+ echo ' Installation (global) failed.' >&2
262+ return 1
263+ fi
264+ fi
265+ echo ' Successfully installed (global).' >&2
266+
232267 return 0
233268}
234269
0 commit comments