Skip to content

Commit 3d92a1f

Browse files
committed
Define a single delete command and add env variable for safe deletion
1 parent ca49af1 commit 3d92a1f

File tree

6 files changed

+35
-17
lines changed

6 files changed

+35
-17
lines changed

Makefile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,16 @@ TESTS_FIXTURES_DIR ?= test/fixtures
6262
# Define the directory name for examples files:
6363
EXAMPLES_DIR ?= examples
6464

65+
# Define whether delete operations should be safe (i.e., deleted items are sent to trash, rather than permanently deleted):
66+
SAFE_DELETE ?= false
67+
68+
# Define the delete command:
69+
ifeq ($(SAFE_DELETE), true)
70+
# FIXME: -rm -rf
71+
DELETE_CMD := -rm -rf
72+
else
73+
DELETE_CMD ?= -rm -rf
74+
endif
6575

6676
# DEPENDENCIES #
6777

tools/make/Makefile

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ NPM ?= npm
77
# Define the command for `node`:
88
NODE ?= node
99

10+
# Define the command for removing files and directories:
11+
DELETE_CMD ?= -rm -rf
12+
1013
# Determine the host kernel:
1114
KERNEL ?= $(shell uname -s)
1215

@@ -40,10 +43,9 @@ include $(TOOLS_MAKE_DIR)/lib/docs/Makefile
4043
#
4144
# This target runs the project's cleanup sequence.
4245

43-
# FIXME: -rm -rf
4446
clean: clean-node clean-cov clean-docs
45-
-rm -rf $(BUILD_DIR)
46-
-rm -rf $(REPORTS_DIR)
47+
$(DELETE_CMD) $(BUILD_DIR)
48+
$(DELETE_CMD) $(REPORTS_DIR)
4749

4850

4951
.PHONY: clean

tools/make/lib/docs/documentationjs.mk

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11

22
# VARIABLES #
33

4+
# Define the command for removing files and directories:
5+
DELETE_CMD ?= -rm -rf
6+
47
# Define the path of the documentation.js executable:
58
DOCUMENTATIONJS ?= $(BIN)/documentation
69

@@ -43,7 +46,7 @@ DOCUMENTATIONJS_JSON_FLAGS ?= --format json
4346
# [2]: https://github.com/documentationjs/documentation
4447

4548
documentationjs-html: node_modules
46-
-rm -rf $(DOCUMENTATIONJS_HTML_OUT)
49+
$(DELETE_CMD) $(DOCUMENTATIONJS_HTML_OUT)
4750
mkdir -p $(DOCUMENTATIONJS_HTML_OUT)
4851
$(DOCUMENTATIONJS) $(DOCUMENTATIONJS_HTML_FLAGS) $(DOCUMENTATIONJS_TYPEDEF) $(SOURCES)
4952

@@ -59,7 +62,7 @@ documentationjs-html: node_modules
5962
# [2]: https://github.com/documentationjs/documentation
6063

6164
documentationjs-json: node_modules
62-
-rm -f $(DOCUMENTATIONJS_JSON_PATH)
65+
$(DELETE_CMD) $(DOCUMENTATIONJS_JSON_PATH)
6366
mkdir -p $(DOCUMENTATIONJS_JSON_OUT)
6467
$(DOCUMENTATIONJS) $(DOCUMENTATIONJS_JSON_FLAGS) $(DOCUMENTATIONJS_TYPEDEF) $(SOURCES) > $(DOCUMENTATIONJS_JSON_PATH)
6568

@@ -76,9 +79,8 @@ view-documentationjs-html:
7679
#
7780
# This target cleans up a documentation.js output directory by removing it entirely.
7881

79-
# FIXME: -rm -rf
8082
clean-documentationjs:
81-
-rm -rf $(DOCUMENTATIONJS_OUT)
83+
$(DELETE_CMD) $(DOCUMENTATIONJS_OUT)
8284

8385

8486
# Rebuild HTML documentation.

tools/make/lib/docs/jsdoc.mk

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11

22
# VARIABLES #
33

4+
# Define the command for removing files and directories:
5+
DELETE_CMD ?= -rm -rf
6+
47
# Define the path of the JSDoc executable:
58
JSDOC ?= $(BIN)/jsdoc
69

@@ -56,9 +59,8 @@ JSDOC_JSON_FLAGS ?= --template $(JSDOC_JSON_TEMPLATE) \
5659
#
5760
# [1]: http://usejsdoc.org/
5861

59-
# FIXME: -rm -rf
6062
jsdoc-html: node_modules
61-
-rm -rf $(JSDOC_HTML_OUT)
63+
$(DELETE_CMD) $(JSDOC_HTML_OUT)
6264
mkdir -p $(JSDOC_HTML_OUT)
6365
$(JSDOC) $(JSDOC_HTML_FLAGS) $(JSDOC_TYPEDEF) $(SOURCES)
6466

@@ -72,9 +74,8 @@ jsdoc-html: node_modules
7274
#
7375
# [1]: http://usejsdoc.org/
7476

75-
# FIXME: -rm -rf
7677
jsdoc-json: node_modules
77-
-rm -f $(JSDOC_JSON_PATH)
78+
$(DELETE_CMD) $(JSDOC_JSON_PATH)
7879
mkdir -p $(JSDOC_JSON_OUT)
7980
$(JSDOC) $(JSDOC_JSON_FLAGS) $(JSDOC_TYPEDEF) $(SOURCES) > $(JSDOC_JSON_PATH)
8081

@@ -91,9 +92,8 @@ view-jsdoc-html:
9192
#
9293
# This target cleans up a JSDoc output directory by removing it entirely.
9394

94-
# FIXME: -rm -rf
9595
clean-jsdoc:
96-
-rm -rf $(JSDOC_OUT)
96+
$(DELETE_CMD) $(JSDOC_OUT)
9797

9898

9999
# Rebuild JSDoc HTML documentation.

tools/make/lib/install/node.mk

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
# Define the command for `npm`:
55
NPM ?= npm
66

7+
# Define the command for removing files and directories:
8+
DELETE_CMD ?= -rm -rf
9+
710

811
# TARGETS #
912

@@ -21,9 +24,8 @@ install-node: package.json
2124
#
2225
# This target cleans the `node_modules` directory by removing it entirely.
2326

24-
# FIXME: -rm -rf
2527
clean-node:
26-
-rm -rf $(NODE_MODULES)
28+
$(DELETE_CMD) $(NODE_MODULES)
2729

2830

2931
.PHONY: install-node clean-node

tools/make/lib/test-cov/Makefile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33

44
CODE_COV_INSTRUMENTATION ?= istanbul
55

6+
# Define the command for removing files and directories:
7+
DELETE_CMD ?= -rm -rf
8+
69

710
# DEPENDENCIES #
811

@@ -37,9 +40,8 @@ endif
3740
#
3841
# This target cleans up a coverage directory by removing it entirely.
3942

40-
# FIXME: -rm -rf
4143
clean-cov:
42-
-rm -rf $(COVERAGE_DIR)
44+
$(DELETE_CMD) $(COVERAGE_DIR)
4345

4446

4547
.PHONY: test-cov view-cov clean-cov

0 commit comments

Comments
 (0)