Skip to content

Commit 43ac682

Browse files
committed
Add rule for testing whether a pkg installs from npm
1 parent d736897 commit 43ac682

2 files changed

Lines changed: 57 additions & 0 deletions

File tree

tools/make/lib/node/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
include $(TOOLS_MAKE_LIB_DIR)/node/addons.mk
2222
include $(TOOLS_MAKE_LIB_DIR)/node/modules.mk
2323
include $(TOOLS_MAKE_LIB_DIR)/node/npm.mk
24+
include $(TOOLS_MAKE_LIB_DIR)/node/test_install.mk
2425

2526

2627
# TARGETS #
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#/
2+
# @license Apache-2.0
3+
#
4+
# Copyright (c) 2018 The Stdlib Authors.
5+
#
6+
# Licensed under the Apache License, Version 2.0 (the "License");
7+
# you may not use this file except in compliance with the License.
8+
# You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
#/
18+
19+
# VARIABLES #
20+
21+
# Define the directory path where the package should be installed:
22+
TEST_NPM_INSTALL_DIR ?= $(BUILD_DIR)/test-npm-install
23+
24+
# Define the package to be test:
25+
TEST_NPM_INSTALL_PKG ?= $(shell $(PROJECT_NAME))
26+
27+
# Define the package version to install:
28+
TEST_NPM_INSTALL_VERSION ?= latest
29+
30+
31+
# RULES #
32+
33+
#/
34+
# Tests whether a package can be successfully installed via `npm install`.
35+
#
36+
# @example
37+
# make test-npm-install
38+
#/
39+
test-npm-install: clean-test-npm-install
40+
$(QUIET) $(MKDIR_RECURSIVE) $(TEST_NPM_INSTALL_DIR) && \
41+
cd $(TEST_NPM_INSTALL_DIR) && \
42+
echo '{"name":"test-npm-install","version":"0.0.0","private":true}' > $(TEST_NPM_INSTALL_DIR)/package.json && \
43+
$(NPM) install "$(TEST_NPM_INSTALL_PKG)@$(TEST_NPM_INSTALL_VERSION)"
44+
45+
.PHONY: test-npm-install
46+
47+
#/
48+
# Removes the test installation.
49+
#
50+
# @example
51+
# make clean-test-npm-install
52+
#/
53+
clean-test-npm-install:
54+
$(QUIET) $(DELETE) $(DELETE_FLAGS) $(TEST_NPM_INSTALL_DIR)
55+
56+
.PHONY: clean-test-npm-install

0 commit comments

Comments
 (0)