Skip to content

Commit 41ab412

Browse files
FIX: Simplify Windows run logic in Makefile
1 parent 7cde38f commit 41ab412

File tree

3 files changed

+27
-45
lines changed

3 files changed

+27
-45
lines changed

Commits List Splitter by File First Appearance/Makefile

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,25 +23,19 @@ LOG_DIR := ./Logs
2323
# Ensure logs directory exists (cross-platform)
2424
ENSURE_LOG_DIR := @mkdir -p $(LOG_DIR) 2>/dev/null || $(PYTHON_CMD) -c "import os; os.makedirs('$(LOG_DIR)', exist_ok=True)"
2525

26-
# Run-and-log function, supports DETACH variable
27-
# If DETACH is set, runs the script in detached mode and tails the log file
28-
# Else, runs the script normally
29-
# Run-and-log function, DETACH controls detached execution
26+
# Run-and-log function
27+
# On Windows: simply runs the Python script normally
28+
# On Unix-like systems: supports DETACH variable
29+
# - If DETACH is set, runs the script in detached mode and tails the log file
30+
# - Else, runs the script normally
3031
ifeq ($(OS), Windows) # Windows
31-
RUN_AND_LOG = \
32+
RUN_AND_LOG = $(PYTHON) $(1)
33+
else
34+
RUN_AND_LOG = \ # Unix-like
3235
if [ -z "$(DETACH)" ]; then \
3336
$(PYTHON) $(1); \
3437
else \
35-
LOG_FILE=$(LOG_DIR)/$$(basename $(basename $(1))).log; \
36-
start /B cmd /c "$(PYTHON) $(1)"; \
37-
powershell -Command "Get-Content -Path '$$LOG_FILE' -Wait"; \
38-
fi
39-
else # Unix-like
40-
RUN_AND_LOG = \
41-
if [ -z "$(DETACH)" ]; then \
42-
$(PYTHON) $(1); \
43-
else \
44-
LOG_FILE=$(LOG_DIR)/$$(basename $(basename $(1))).log; \
38+
LOG_FILE=$(LOG_DIR)/$$(basename $(1) .py).log; \
4539
nohup $(PYTHON) $(1) > $$LOG_FILE 2>&1 & \
4640
tail -f $$LOG_FILE; \
4741
fi

Main Template/Makefile

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,25 +23,19 @@ LOG_DIR := ./Logs
2323
# Ensure logs directory exists (cross-platform)
2424
ENSURE_LOG_DIR := @mkdir -p $(LOG_DIR) 2>/dev/null || $(PYTHON_CMD) -c "import os; os.makedirs('$(LOG_DIR)', exist_ok=True)"
2525

26-
# Run-and-log function, supports DETACH variable
27-
# If DETACH is set, runs the script in detached mode and tails the log file
28-
# Else, runs the script normally
29-
# Run-and-log function, DETACH controls detached execution
26+
# Run-and-log function
27+
# On Windows: simply runs the Python script normally
28+
# On Unix-like systems: supports DETACH variable
29+
# - If DETACH is set, runs the script in detached mode and tails the log file
30+
# - Else, runs the script normally
3031
ifeq ($(OS), Windows) # Windows
31-
RUN_AND_LOG = \
32+
RUN_AND_LOG = $(PYTHON) $(1)
33+
else
34+
RUN_AND_LOG = \ # Unix-like
3235
if [ -z "$(DETACH)" ]; then \
3336
$(PYTHON) $(1); \
3437
else \
35-
LOG_FILE=$(LOG_DIR)/$$(basename $(basename $(1))).log; \
36-
start /B cmd /c "$(PYTHON) $(1)"; \
37-
powershell -Command "Get-Content -Path '$$LOG_FILE' -Wait"; \
38-
fi
39-
else # Unix-like
40-
RUN_AND_LOG = \
41-
if [ -z "$(DETACH)" ]; then \
42-
$(PYTHON) $(1); \
43-
else \
44-
LOG_FILE=$(LOG_DIR)/$$(basename $(basename $(1))).log; \
38+
LOG_FILE=$(LOG_DIR)/$$(basename $(1) .py).log; \
4539
nohup $(PYTHON) $(1) > $$LOG_FILE 2>&1 & \
4640
tail -f $$LOG_FILE; \
4741
fi

Subtitles Translations with DeepL/Makefile

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,25 +23,19 @@ LOG_DIR := ./Logs
2323
# Ensure logs directory exists (cross-platform)
2424
ENSURE_LOG_DIR := @mkdir -p $(LOG_DIR) 2>/dev/null || $(PYTHON_CMD) -c "import os; os.makedirs('$(LOG_DIR)', exist_ok=True)"
2525

26-
# Run-and-log function, supports DETACH variable
27-
# If DETACH is set, runs the script in detached mode and tails the log file
28-
# Else, runs the script normally
29-
# Run-and-log function, DETACH controls detached execution
26+
# Run-and-log function
27+
# On Windows: simply runs the Python script normally
28+
# On Unix-like systems: supports DETACH variable
29+
# - If DETACH is set, runs the script in detached mode and tails the log file
30+
# - Else, runs the script normally
3031
ifeq ($(OS), Windows) # Windows
31-
RUN_AND_LOG = \
32+
RUN_AND_LOG = $(PYTHON) $(1)
33+
else
34+
RUN_AND_LOG = \ # Unix-like
3235
if [ -z "$(DETACH)" ]; then \
3336
$(PYTHON) $(1); \
3437
else \
35-
LOG_FILE=$(LOG_DIR)/$$(basename $(basename $(1))).log; \
36-
start /B cmd /c "$(PYTHON) $(1)"; \
37-
powershell -Command "Get-Content -Path '$$LOG_FILE' -Wait"; \
38-
fi
39-
else # Unix-like
40-
RUN_AND_LOG = \
41-
if [ -z "$(DETACH)" ]; then \
42-
$(PYTHON) $(1); \
43-
else \
44-
LOG_FILE=$(LOG_DIR)/$$(basename $(basename $(1))).log; \
38+
LOG_FILE=$(LOG_DIR)/$$(basename $(1) .py).log; \
4539
nohup $(PYTHON) $(1) > $$LOG_FILE 2>&1 & \
4640
tail -f $$LOG_FILE; \
4741
fi

0 commit comments

Comments
 (0)