Skip to content

Commit 5dc2128

Browse files
committed
chore: update deps, min node.js, ci main.yml, tsconfig.json, vitest testTimeout; fix __dirname
1 parent 35246fa commit 5dc2128

File tree

7 files changed

+1333
-453
lines changed

7 files changed

+1333
-453
lines changed

.github/workflows/main.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,13 @@ on:
1010
branches: ['main']
1111

1212
jobs:
13-
build:
13+
build_and_test:
1414
runs-on: ubuntu-latest
1515

1616
strategy:
1717
matrix:
18-
node-version: [18.x, 20.x]
18+
node-version:
19+
- 20.9.x
1920
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
2021

2122
steps:
@@ -24,8 +25,7 @@ jobs:
2425
uses: actions/setup-node@v4
2526
with:
2627
node-version: ${{ matrix.node-version }}
27-
cache: 'npm'
2828
- run: npm ci
2929
- run: npm run lint
30-
- run: npm run build --if-present
30+
- run: npm run build
3131
- run: npm test

README.md

Lines changed: 39 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,45 @@
11
# img-dl
22

3-
Downloade image(s), by command or programmatically. The alternative for `image-downloader` package (see the [comparison](#comparison)).
3+
Downloade image(s), by command or programmatically. The alternative for `image-downloader` package (see the [features](#features)).
44

55
[![MIT license](https://img.shields.io/github/license/fityannugroho/img-dl.svg)](https://github.com/fityannugroho/img-dl/blob/main/LICENSE)
66
[![npm version](https://img.shields.io/npm/v/img-dl.svg)](https://www.npmjs.com/package/img-dl)
77
[![npm downloads](https://img.shields.io/npm/dm/img-dl.svg)](https://www.npmjs.com/package/img-dl)
88
[![install size](https://packagephobia.com/badge?p=img-dl)](https://packagephobia.com/result?p=img-dl)
99

10+
## Features
11+
12+
| Features | **img-dl** | [image-downloader][p1] |
13+
| --------------------------- | :--------: | :--------------------: |
14+
| Single download |||
15+
| Bulk download |||
16+
| CLI |||
17+
| Custom filename |||
18+
| Custom extension |||
19+
| Request timeout |||
20+
| Retry failed request |||
21+
| Abort request |||
22+
| **Increment mode (in CLI)** |||
23+
| **Overwrite prevention** |||
24+
25+
### Increment mode
26+
27+
Download images with an url that contains `{i}` placeholder for the index, and specify the start and end index.
28+
29+
### Overwrite prevention
30+
31+
To prevent overwriting, ` (n)` will be appended to the name of the new file if the file with the same name already exists.
32+
33+
The number will be incremented until the file name is unique in the directory, starting from 1 (e.g. `image (1).jpg`, `image (2).jpg`, etc.).
34+
35+
Image with different extension will be considered as **different** file, so it will not be appended with ` (n)`. For example, `image.jpg` and `image.png` will not be considered as the same file.
36+
37+
> This feature will work for both single and bulk download.
38+
1039
## Prerequisites
1140

12-
- Node.js 18 or later
13-
- npm 9 or later
41+
- Node.js 20.9 or later
42+
- npm 10 or later
1443

1544
## Installation
1645

@@ -43,7 +72,7 @@ USAGE
4372
PARAMETERS
4473
url The URL of the image to download. Provide multiple URLs to download multiple images.
4574
In increment mode, the URL must contain {i} placeholder for the index,
46-
only one URL is allowed, and the 'end' flag is required.
75+
only one URL is allowed, and the '--end' is required.
4776
4877
OPTIONS
4978
-d, --dir=<path> The output directory. Default: current working directory
@@ -53,7 +82,7 @@ OPTIONS
5382
-H, --header=<header> The header to send with the request. Can be used multiple times
5483
-i, --increment Enable increment mode. Default: false
5584
--interval=<number> The interval between each batch of requests in milliseconds
56-
-n, --name=<filename> The filename. Default: original filename or timestamp
85+
-n, --name=<filename> The filename. If not specified, the original filename will be used. Default: 'image'
5786
--max-retry=<number> Set the maximum number of times to retry the request if it fails
5887
--silent Disable logging
5988
--start=<number> The start index for increment mode. Default: 0
@@ -76,13 +105,13 @@ EXAMPLES
76105
imgdl https://example.com/image.jpg
77106
```
78107

79-
#### Download multiple images
108+
#### Bulk download
80109

81110
```bash
82111
imgdl https://example.com/image.jpg https://example.com/image2.jpg
83112
```
84113

85-
#### Download multiple images with increment mode
114+
#### Bulk download with increment mode
86115

87116
```bash
88117
imgdl https://example.com/image-{i}.jpg --increment --start=1 --end=10
@@ -110,7 +139,7 @@ console.log(image);
110139
*/
111140
```
112141

113-
#### Download multiple images
142+
#### Bulk download
114143

115144
```js
116145
import imgdl from 'img-dl';
@@ -172,7 +201,7 @@ The interval between each batch of requests in milliseconds when downloading mul
172201
Type: `string`<br>
173202
Default: `'image'`
174203

175-
The filename. If not specified, the original filename will be used. If the original filename is not available, 'image' will be used. <br>When downloading multiple images, `-index` will be appended to the end of the name (suffix). `index` will start from 1. For example: 'image-1'
204+
The filename. If not specified, the original filename will be used. If the original filename is not available, 'image' will be used.
176205

177206
##### `maxRetry`
178207

@@ -216,20 +245,6 @@ Default: `undefined`
216245

217246
Set timeout for each request in milliseconds.
218247

219-
## Comparison
220-
221-
| Features | **img-dl** | [image-downloader][p1] |
222-
| ------------------------ | :--------: | :--------------------: |
223-
| Download single image |||
224-
| Download multiple images |||
225-
| CLI |||
226-
| Increment download |||
227-
| Custom filename |||
228-
| Custom extension |||
229-
| Request timeout |||
230-
| Retry failed request |||
231-
| Abort request |||
232-
233248
<!-- Project links -->
234249

235250
[p1]: https://www.npmjs.com/package/image-downloader
@@ -238,4 +253,4 @@ Set timeout for each request in milliseconds.
238253

239254
Give a ⭐️ if this project helped you!
240255

241-
You can support this project by donating via [GitHub Sponsors](https://github.com/sponsors/fityannugroho), [Trakteer](https://trakteer.id/fityannugroho/tip), or [Saweria](https://saweria.co/fityannugroho).
256+
Also please consider supporting this project with a **donation**. Your donation will help us maintain and develop this project and provide you with better support.

0 commit comments

Comments
 (0)