You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+60-8Lines changed: 60 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,29 +2,81 @@ English | [中文](./README_zh.md)
2
2
3
3
# Resource Saving Script
4
4
5
-
A simple but powerful Node.js script that runs a local web server and automatically downloads missing resources.
5
+
A Node.js tool for local development that starts a local server while automatically fetching missing remote resource files.
6
6
7
-
### Global Installation
7
+
## Table of Contents
8
+
9
+
-[Installation](#installation)
10
+
-[Usage](#usage)
11
+
-[How It Works](#how-it-works)
12
+
-[Usage Example](#usage-example)
13
+
-[Use Cases](#use-cases)
14
+
15
+
## Installation
8
16
9
17
```bash
10
18
npm install -g resource-save-script
11
19
```
12
20
13
-
###Usage
21
+
## Usage
14
22
15
-
Once installed, you can use the `h` command in your terminal.
23
+
Once installed, use the `h` command in your terminal:
16
24
17
25
```bash
18
-
# Run on a custom port (e.g., 8080)
26
+
# Run on a custom port
19
27
h 8080
20
28
21
-
# Run on the default port (4000)
29
+
# Run on the default port 4000
22
30
h
23
31
```
24
32
25
-
After running the command, the script will prompt you to enter the base URL of the remote server where the resources are located.
33
+
You'll be prompted to enter the remote server URL:
26
34
27
35
```text
28
36
→ Please enter the base URL for resources: https://your-remote-server.com
29
37
```
30
-
The local server will then start, and any missing files will be downloaded automatically.
38
+
39
+
## How It Works
40
+
41
+
The script monitors 404 requests on the local server. When a missing file is detected, it automatically downloads the file from the specified remote server to your local directory.
42
+
43
+
## Usage Example
44
+
45
+
Let's say you want to debug a page from `luckfunc.com` locally:
46
+
47
+
**1. Create and enter project directory**
48
+
```bash
49
+
mkdir my-project
50
+
cd my-project
51
+
```
52
+
53
+
**2. Download the main page**
54
+
```bash
55
+
curl -o index.html https://luckfunc.com/
56
+
```
57
+
58
+
**3. Start the script in your project directory**
59
+
```bash
60
+
h
61
+
# Enter: https://luckfunc.com/
62
+
```
63
+
64
+
**4. Access the page**
65
+
66
+
Open your browser and visit `http://127.0.0.1:4000/index.html`
67
+
68
+
When the page loads, if it references local files like `i18n.js` that don't exist, the script will automatically download them from `luckfunc.com` to your local directory.
0 commit comments