logo

overlay

My own overlay for experimentations, use with caution, no support is provided git clone https://hacktivis.me/git/overlay.git
commit: c17bf40bbc2f9c099221145eadf3f0c70e8a3a68
parent f61c27c36cb75c54f485e504305195a6866a8d1d
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Sun, 14 Aug 2022 07:36:39 +0200

eclass/nodejs.eclass: New

Diffstat:

Aeclass/nodejs.eclass38++++++++++++++++++++++++++++++++++++++
1 file changed, 38 insertions(+), 0 deletions(-)

diff --git a/eclass/nodejs.eclass b/eclass/nodejs.eclass @@ -0,0 +1,38 @@ +# Copyright 2022 Haelwenn (lanodan) Monnier <contact@hacktivis.me> +# Distributed under the terms of the GNU General Public License v2 + +# @ECLASS: nodejs.eclass +# @MAINTAINER: +# Haelwenn (lanodan) Monnier <contact@hacktivis.me> +# @AUTHOR: +# Haelwenn (lanodan) Monnier <contact@hacktivis.me> +# @SUPPORTED_EAPIS: 7 8 +# @BLURB: Build NodeJS projects +# @DESCRIPTION: +# An eclass providing functions to build NodeJS projects + +case "${EAPI:-0}" in + 7|8) + ;; + *) + die "Unsupported EAPI=${EAPI} for ${ECLASS}" + ;; +esac + +EXPORT_FUNCTIONS src_test + +BDEPEND=" + net-libs/nodejs + app-misc/jq +" + +NODEJS_SITELIB="/usr/share/nodejs/" + +nodejs_src_test() { + if jq -e '.scripts | has("test")' <package.json >/dev/null + then + npm run test || die + else + die 'No "test" command defined in package.json' + fi +}