commit:     fab8c591587117c50df1247d3ac7d81fe00c10a6
Author:     Samuel Bernardo <samuelbernardo.mail <AT> gmail <DOT> com>
AuthorDate: Sun Jun 24 22:25:59 2018 +0000
Commit:     Samuel Bernardo <samuelbernardo.mail <AT> gmail <DOT> com>
CommitDate: Sun Jun 24 22:25:59 2018 +0000
URL:        https://gitweb.gentoo.org/repo/user/ssnb.git/commit/?id=fab8c591

add npm-tools.eclass and update opennebula 5.4.15 to use this new eclass

 app-emulation/opennebula/opennebula-5.4.15.ebuild |  6 +--
 eclass/npm-tools.eclass                           | 45 +++++++++++++++++++++++
 2 files changed, 47 insertions(+), 4 deletions(-)

diff --git a/app-emulation/opennebula/opennebula-5.4.15.ebuild 
b/app-emulation/opennebula/opennebula-5.4.15.ebuild
index 9ed761b..55fff2b 100644
--- a/app-emulation/opennebula/opennebula-5.4.15.ebuild
+++ b/app-emulation/opennebula/opennebula-5.4.15.ebuild
@@ -5,7 +5,7 @@
 EAPI=6
 USE_RUBY="ruby22 ruby23 ruby24 ruby25"
 
-inherit user eutils multilib ruby-ng systemd git-r3 flag-o-matic
+inherit user eutils multilib ruby-ng systemd git-r3 flag-o-matic npm-tools
 
 MY_P="opennebula-${PV/_/-}"
 
@@ -106,9 +106,7 @@ src_compile() {
 
        # install necessary npm project dependencies
        if use sunstone; then
-               cd ${S}/src/sunstone/public/
-               /usr/bin/npm install -f
-               cd ${S}
+               npm_install ${S}/src/sunstone/public/
        fi
 
        local myconf

diff --git a/eclass/npm-tools.eclass b/eclass/npm-tools.eclass
new file mode 100644
index 0000000..6dcc821
--- /dev/null
+++ b/eclass/npm-tools.eclass
@@ -0,0 +1,45 @@
+# Copyright 1999-2018 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+# @ECLASS: npm-tools.eclass
+# @MAINTAINER:
+# [email protected]
+# @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)
+       npm_install() {
+               local dir="$1"
+               if [[ -z "${dir}" ]] ; then
+                       $(which npm) install
+               else
+                       pushd ${dir}
+                       $(which npm) install
+                       popd
+               fi
+       }
+       ;;
+esac
+
+fi

Reply via email to