Skip to content

Commit 5c19e4f

Browse files
style(Rest): standardize shell redirection spacing and quote style
Add POSIX-compliant spacing to shell script redirections (>/dev/null to > /dev/null) across Bench.sh, prepublishOnly.sh, and run_tests.sh. Continue JavaScript quote style standardization in bin/Rest.js, converting remaining double quotes to single quotes to match project guidelines. These changes align with the recent POSIX compliance and quote style standardization efforts in the Rest element.
1 parent f30f8ce commit 5c19e4f

File tree

4 files changed

+34
-29
lines changed

4 files changed

+34
-29
lines changed
Lines changed: 11 additions & 11 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,7 +97,7 @@ 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

@@ -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

@@ -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: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,35 @@
22
/**
33
* Rest.js - CLI wrapper for Rest compiler binary
44
*/
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';
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";
109

1110
const __dirname = dirname(fileURLToPath(import.meta.url));
1211

1312
// Determine the binary path based on platform
1413
const platform = process.platform;
15-
const binaryName = platform === 'win32' ? 'Rest.exe' : 'Rest';
14+
const binaryName = platform === "win32" ? "Rest.exe" : "Rest";
1615
const binaryPath = join(__dirname, binaryName);
1716

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

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

prepublishOnly.sh

Lines changed: 4 additions & 4 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
@@ -138,7 +138,7 @@ esac
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)