Skip to content

Commit 2cc2633

Browse files
committed
Fix jekyll startup issues
1 parent b0cc029 commit 2cc2633

File tree

5 files changed

+43
-19
lines changed

5 files changed

+43
-19
lines changed

docs/_config.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ url: "https://sylhare.github.io"
77

88
# Build settings
99
markdown: kramdown
10+
encoding: utf-8
1011
sass:
1112
style: compressed
1213

docs/_plugins/simple_search_filter.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# encoding: utf-8
2+
# frozen_string_literal: true
3+
14
# Example usage in a Jekyll template:
25
# {{ some_variable | remove_chars }}
36
#

docs/_plugins/simple_search_filter_cn.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# encoding: utf-8
2+
# frozen_string_literal: true
3+
14
# Same as `simple_search_filter.rb`, but with additional adapted for Chinese characters
25
# Example usage in a Jekyll template:
36
# {{ some_variable | remove_chars_cn }}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"scripts": {
88
"cypress": "cypress",
99
"cypress:ci": "node scripts/start-jekyll.js & sleep 5 && cypress run",
10-
"cypress:run": "node scripts/start-jekyll.js & sleep 5 && cypress run && node scripts/kill-jekyll.js",
10+
"cypress:run": "node scripts/start-jekyll.js && sleep 8 && cypress run; EXIT_CODE=$?; node scripts/kill-jekyll.js; exit $EXIT_CODE",
1111
"lint": "eslint . --ext .ts",
1212
"pretest": "yarn run lint",
1313
"build": "tsc && vite build && terser dest/simple-jekyll-search.js -o dest/simple-jekyll-search.min.js",

scripts/start-jekyll.js

Lines changed: 35 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,40 @@
1-
import { spawn } from 'child_process';
1+
import { spawn, exec } from 'child_process';
22

3-
console.log('Starting Jekyll server in detached mode...');
3+
console.log('Checking for processes on port 4000...');
44

5-
const jekyllProcess = spawn('bundle', ['exec', 'jekyll', 'serve', '--detach'], {
6-
cwd: 'docs',
7-
stdio: 'inherit', // Ensures output is displayed in the terminal
8-
shell: true, // Allows running shell commands
9-
});
10-
11-
jekyllProcess.on('error', (error) => {
12-
console.error('Error starting Jekyll server:', error.message);
13-
process.exit(1);
14-
});
15-
16-
jekyllProcess.on('close', (code) => {
17-
if (code === 0) {
18-
console.log('Jekyll server started successfully!');
5+
// Kill any process using port 4000
6+
exec('lsof -ti:4000 | xargs kill -9 2>/dev/null || true', (error, stdout, stderr) => {
7+
if (stdout) {
8+
console.log('Killed process on port 4000');
199
} else {
20-
console.error(`Jekyll server exited with code ${code}`);
10+
console.log('No process found on port 4000');
2111
}
22-
process.exit(code);
12+
13+
console.log('Starting Jekyll server in detached mode...');
14+
15+
const jekyllProcess = spawn('bundle', ['exec', 'jekyll', 'serve', '--detach'], {
16+
cwd: 'docs',
17+
stdio: 'inherit',
18+
shell: true,
19+
env: {
20+
...process.env,
21+
LANG: 'en_US.UTF-8',
22+
LC_ALL: 'en_US.UTF-8',
23+
LC_CTYPE: 'en_US.UTF-8'
24+
}
25+
});
26+
27+
jekyllProcess.on('error', (error) => {
28+
console.error('Error starting Jekyll server:', error.message);
29+
process.exit(1);
30+
});
31+
32+
jekyllProcess.on('close', (code) => {
33+
if (code === 0) {
34+
console.log('Jekyll server started successfully!');
35+
} else {
36+
console.error(`Jekyll server exited with code ${code}`);
37+
}
38+
process.exit(code);
39+
});
2340
});

0 commit comments

Comments
 (0)