aboutsummaryrefslogtreecommitdiff
blob: 470924d19cb06fde1847d7316b21658fb2dbbd74 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# Copyright 1999-2020 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

# @ECLASS: npm-tools.eclass
# @MAINTAINER:
# samuelbernardo@gmail.com
# @BLURB: functions to install project nodejs dependencies
# @DESCRIPTION:
# The npm-tools eclass contains functions to manage nodejs package
# for projects that needs it.
#
# For more details review the following url:
# https://gruntjs.com/getting-started

if [[ -z ${_NPM_TOOLS_ECLASS} ]]; then
_NPM_TOOLS_ECLASS=1

# implicitly inherited eclasses
#case ${EAPI:-0} in
#0|1|2|3|4|5|6)
#	inherit eutils
#	;;
#esac

# @FUNCTION: npm_install
# @USAGE: [project dir]
# @DESCRIPTION:
# Run npm install in the provided project directory.
# If no directory is provided it will run on current path.
case ${EAPI:-0} in
5|6|7)
	npm_install() {
		local dir="$1"
		if [[ -z "${dir}" ]] ; then
			$(which npm) install
		else
			pushd ${dir}
			$(which npm) install
			popd
		fi
	}
	;;
esac

fi