mirror of
https://github.com/kucherenko/jscpd.git
synced 2026-09-19 08:11:03 +08:00
64e471e2b0
Adds 92 new tests (178 → 270 total) with zero source-file modifications: - packages/finder: 13 new test files covering all reporters, subscribers, validators, hooks, utils, options, cloneFound, getFilesToDetect, and InFilesDetector; shared buildClone() factory helper - apps/jscpd: 3 new test files (options-unit, print, store) plus extensions to formats, modes, and options integration tests - vitest.config.ts added to both packages to restrict coverage.include to src/** only, eliminating bin/ and prism.js noise - Fixes 3 tokenizer bugs (trailing space in format lookup, tokenization edge cases) uncovered by the new format fixture suite - Adds fixture files for 40+ language formats to support formats.test.ts
40 lines
814 B
Bash
40 lines
814 B
Bash
#!/bin/bash
|
|
|
|
# Common utility functions
|
|
log_message() {
|
|
local level="$1"
|
|
local message="$2"
|
|
echo "[$(date +%Y-%m-%d\ %H:%M:%S)] [$level] $message"
|
|
}
|
|
|
|
check_root() {
|
|
if [ "$(id -u)" -ne 0 ]; then
|
|
log_message "ERROR" "This script must be run as root"
|
|
exit 1
|
|
fi
|
|
}
|
|
|
|
setup_directories() {
|
|
local base_dir="$1"
|
|
mkdir -p "$base_dir/logs"
|
|
mkdir -p "$base_dir/tmp"
|
|
mkdir -p "$base_dir/config"
|
|
log_message "INFO" "Created directory structure under $base_dir"
|
|
}
|
|
|
|
validate_input() {
|
|
local input="$1"
|
|
if [ -z "$input" ]; then
|
|
log_message "ERROR" "Input cannot be empty"
|
|
return 1
|
|
fi
|
|
return 0
|
|
}
|
|
|
|
# Script-specific: stop service
|
|
stop_service() {
|
|
local service="$1"
|
|
systemctl stop "$service"
|
|
log_message "INFO" "Stopped $service"
|
|
}
|