Skip to content

Commit cd100e9

Browse files
style(Rest): remove spaces from shell redirection operators
Continue POSIX compliance by removing extraneous spaces from shell redirection operators across Bench.sh, prepublishOnly.sh, and run_tests.sh. Change `2> /dev/null` to `2>/dev/null` and `> /dev/null` to `>/dev/null` for consistent POSIX-style redirection. Also continue JavaScript quote style standardization in bin/Rest.js by ensuring all double quotes are converted to single quotes.
1 parent 5c19e4f commit cd100e9

4 files changed

Lines changed: 63 additions & 68 deletions

File tree

Bench.sh

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,12 @@ echo ""
4747

4848
# Function to count TypeScript files
4949
count_typescript_files() {
50-
find "$1" -name "*.ts" -type f 2> /dev/null \
51-
| grep -v "node_modules" \
52-
| grep -v "Target" \
53-
| grep -v "/test" \
54-
| grep -v "\.d\.ts$" \
55-
| wc -l
50+
find "$1" -name "*.ts" -type f 2>/dev/null |
51+
grep -v "node_modules" |
52+
grep -v "Target" |
53+
grep -v "/test" |
54+
grep -v "\.d\.ts$" |
55+
wc -l
5656
}
5757

5858
# Function to compile with Rest
@@ -97,11 +97,11 @@ benchmark_rest() {
9797
printf " Total time: %d seconds\n" "$elapsed"
9898

9999
if [ -d "$output_dir" ]; then
100-
compiled_count=$(find "$output_dir" -name "*.js" -type f 2> /dev/null | grep -v "map" | wc -l)
100+
compiled_count=$(find "$output_dir" -name "*.js" -type f 2>/dev/null | grep -v "map" | wc -l)
101101
echo " Output files: $compiled_count"
102102
echo " Output size: $(du -sh "$output_dir" | cut -f1)"
103103

104-
printf "%s,%s,%s,%s\n" "$file_count" "$compiled_count" "$exit_code" "$elapsed" > "$output_dir/benchmark_results.csv"
104+
printf "%s,%s,%s,%s\n" "$file_count" "$compiled_count" "$exit_code" "$elapsed" >"$output_dir/benchmark_results.csv"
105105
else
106106
echo " No output directory created"
107107
fi
@@ -126,8 +126,8 @@ compare_outputs() {
126126
echo "Finding VSCode JavaScript files..."
127127
echo "Finding Rest JavaScript files..."
128128

129-
total_vscode=$(find "$vscode_dir" -name "*.js" -type f 2> /dev/null | grep -v "map" | grep -v "\.d\.js$" | wc -l)
130-
total_rest=$(find "$rest_dir" -name "*.js" -type f 2> /dev/null | grep -v "map" | grep -v "\.d\.js$" | wc -l)
129+
total_vscode=$(find "$vscode_dir" -name "*.js" -type f 2>/dev/null | grep -v "map" | grep -v "\.d\.js$" | wc -l)
130+
total_rest=$(find "$rest_dir" -name "*.js" -type f 2>/dev/null | grep -v "map" | grep -v "\.d\.js$" | wc -l)
131131

132132
echo "VSCode: $total_vscode files, Rest: $total_rest files"
133133

@@ -146,7 +146,7 @@ compare_outputs() {
146146
mismatch_count=0
147147
missing_count=0
148148

149-
find "$vscode_dir" -name "*.js" -type f 2> /dev/null | grep -v "map" | grep -v "\.d\.js$" | while IFS= read -r vscode_file; do
149+
find "$vscode_dir" -name "*.js" -type f 2>/dev/null | grep -v "map" | grep -v "\.d\.js$" | while IFS= read -r vscode_file; do
150150
rel="${vscode_file#$vscode_dir/}"
151151
rest_file="$rest_dir/$rel"
152152

@@ -158,8 +158,8 @@ compare_outputs() {
158158
match_count=$((match_count + 1))
159159
else
160160
mismatch_count=$((mismatch_count + 1))
161-
vscode_size=$(wc -c < "$vscode_file")
162-
rest_size=$(wc -c < "$rest_file")
161+
vscode_size=$(wc -c <"$vscode_file")
162+
rest_size=$(wc -c <"$rest_file")
163163
echo " DIFF: $rel (VSCode: ${vscode_size}B, Rest: ${rest_size}B)"
164164
fi
165165
fi
@@ -182,7 +182,7 @@ else
182182
echo "SKIPPING: VSCode source not found or empty"
183183
fi
184184

185-
if [ -d "$VSCode_OUT_BUILD_DIR" ] && [ "$(find "$VSCode_OUT_BUILD_DIR" -name "*.js" 2> /dev/null | wc -l)" -gt 0 ]; then
185+
if [ -d "$VSCode_OUT_BUILD_DIR" ] && [ "$(find "$VSCode_OUT_BUILD_DIR" -name "*.js" 2>/dev/null | wc -l)" -gt 0 ]; then
186186
echo ""
187187
echo "NOTE: Production build requires different compile options"
188188
echo "For now comparing same output with different expected directory"

bin/Rest.js

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,35 +2,30 @@
22
/**
33
* Rest.js - CLI wrapper for Rest compiler binary
44
*/
5-
import { execSync } from "node:child_process";
6-
import { existsSync } from "node:fs";
7-
import { dirname, join } from "node:path";
8-
import { fileURLToPath } from "node:url";
5+
6+
import { execSync } from 'node:child_process';
7+
import { join, dirname } from 'node:path';
8+
import { fileURLToPath } from 'node:url';
9+
import { existsSync } from 'node:fs';
910

1011
const __dirname = dirname(fileURLToPath(import.meta.url));
1112

1213
// Determine the binary path based on platform
1314
const platform = process.platform;
14-
const binaryName = platform === "win32" ? "Rest.exe" : "Rest";
15+
const binaryName = platform === 'win32' ? 'Rest.exe' : 'Rest';
1516
const binaryPath = join(__dirname, binaryName);
1617

1718
if (!existsSync(binaryPath)) {
18-
console.error(`[Rest] Binary not found at: ${binaryPath}`);
19-
console.error("[Rest] Please run: npm install or npm rebuild");
20-
process.exit(1);
19+
console.error(`[Rest] Binary not found at: ${binaryPath}`);
20+
console.error('[Rest] Please run: npm install or npm rebuild');
21+
process.exit(1);
2122
}
2223

2324
// Execute the binary with all arguments
2425
try {
25-
execSync(
26-
`"${binaryPath}" ${process.argv
27-
.slice(2)
28-
.map((a) => `"${a}"`)
29-
.join(" ")}`,
30-
{
31-
stdio: "inherit",
32-
},
33-
);
26+
execSync(`"${binaryPath}" ${process.argv.slice(2).map(a => `"${a}"`).join(' ')}`, {
27+
stdio: 'inherit',
28+
});
3429
} catch (error) {
35-
process.exit(error.status || 1);
30+
process.exit(error.status || 1);
3631
}

prepublishOnly.sh

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,13 @@ log_error() {
3232
}
3333

3434
# Ensure Rust toolchain is configured
35-
if ! command -v rustup > /dev/null 2>&1; then
35+
if ! command -v rustup >/dev/null 2>&1; then
3636
log_error "rustup is not installed. Please install Rust from https://rustup.rs/"
3737
exit 1
3838
fi
3939

4040
# Set default toolchain to stable if not already configured
41-
if ! rustup default > /dev/null 2>&1; then
41+
if ! rustup default >/dev/null 2>&1; then
4242
log_info "Setting Rust default toolchain to stable..."
4343
rustup default stable
4444
fi
@@ -57,7 +57,7 @@ log_info "Starting Rest build for NPM publishing..."
5757
log_info "Working directory: $SCRIPT_DIR"
5858

5959
# Check if Cargo is available
60-
if ! command -v cargo > /dev/null 2>&1; then
60+
if ! command -v cargo >/dev/null 2>&1; then
6161
log_error "Cargo is not installed. Please install Rust from https://rustup.rs/"
6262
exit 1
6363
fi
@@ -70,27 +70,27 @@ detect_target() {
7070
arch=$(uname -m)
7171

7272
case "$platform" in
73-
darwin)
74-
if [ "$arch" = "arm64" ]; then
75-
echo "aarch64-apple-darwin"
76-
else
77-
echo "x86_64-apple-darwin"
78-
fi
79-
;;
80-
linux)
81-
if [ "$arch" = "aarch64" ]; then
82-
echo "aarch64-unknown-linux-gnu"
83-
else
84-
echo "x86_64-unknown-linux-gnu"
85-
fi
86-
;;
87-
msys* | mingw* | cygwin*)
88-
echo "x86_64-pc-windows-msvc"
89-
;;
90-
*)
91-
log_error "Unsupported platform: $platform"
92-
exit 1
93-
;;
73+
darwin)
74+
if [ "$arch" = "arm64" ]; then
75+
echo "aarch64-apple-darwin"
76+
else
77+
echo "x86_64-apple-darwin"
78+
fi
79+
;;
80+
linux)
81+
if [ "$arch" = "aarch64" ]; then
82+
echo "aarch64-unknown-linux-gnu"
83+
else
84+
echo "x86_64-unknown-linux-gnu"
85+
fi
86+
;;
87+
msys* | mingw* | cygwin*)
88+
echo "x86_64-pc-windows-msvc"
89+
;;
90+
*)
91+
log_error "Unsupported platform: $platform"
92+
exit 1
93+
;;
9494
esac
9595
}
9696

@@ -105,12 +105,12 @@ cargo build --release --target "$TARGET"
105105

106106
# Verify the binary was created
107107
case "$TARGET" in
108-
*windows*)
109-
BINARY_PATH="Target/$TARGET/release/Rest.exe"
110-
;;
111-
*)
112-
BINARY_PATH="Target/$TARGET/release/Rest"
113-
;;
108+
*windows*)
109+
BINARY_PATH="Target/$TARGET/release/Rest.exe"
110+
;;
111+
*)
112+
BINARY_PATH="Target/$TARGET/release/Rest"
113+
;;
114114
esac
115115

116116
if [ ! -f "$BINARY_PATH" ]; then
@@ -129,16 +129,16 @@ cp "$BINARY_PATH" "bin/$BINARY_NAME"
129129

130130
# Make the binary executable (Unix-like systems)
131131
case "$TARGET" in
132-
*windows*) ;;
133-
*)
134-
chmod +x "bin/$BINARY_NAME"
135-
;;
132+
*windows*) ;;
133+
*)
134+
chmod +x "bin/$BINARY_NAME"
135+
;;
136136
esac
137137

138138
log_info "Binary copied to: bin/$BINARY_NAME"
139139

140140
# Create the bin wrapper script (Rest.js)
141-
cat > bin/Rest.js << 'EOF'
141+
cat >bin/Rest.js <<'EOF'
142142
#!/usr/bin/env node
143143
/**
144144
* Rest.js - CLI wrapper for Rest compiler binary

run_tests.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ run_test() {
2222
TOTAL_TESTS=$((TOTAL_TESTS + 1))
2323
printf "Test [%s]: %s ... " "$TOTAL_TESTS" "$test_name"
2424

25-
if eval "$test_command" > /dev/null 2>&1; then
25+
if eval "$test_command" >/dev/null 2>&1; then
2626
echo "PASSED"
2727
PASSED_TESTS=$((PASSED_TESTS + 1))
2828
return 0

0 commit comments

Comments
 (0)