@live-change/image-service 0.8.140 → 0.8.142
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/endpoint.js +1 -1
- package/fsUtils.js +5 -26
- package/package.json +4 -4
package/endpoint.js
CHANGED
|
@@ -139,7 +139,7 @@ async function handleImageGet(req, res, params) {
|
|
|
139
139
|
height = Math.round(height * metadata.width / width)
|
|
140
140
|
width = metadata.width
|
|
141
141
|
}
|
|
142
|
-
if(width
|
|
142
|
+
if(width === metadata.width && height === metadata.height) return res.sendFile(sourceFilePath)
|
|
143
143
|
const normalized = normalizeFormat(params.format || metadata.extension)
|
|
144
144
|
const convertedFilePath = path.resolve(imagePrefix + `rect-${width}-${height}.${normalized}`)
|
|
145
145
|
if(!(await fileExists(convertedFilePath))) {
|
package/fsUtils.js
CHANGED
|
@@ -1,40 +1,19 @@
|
|
|
1
|
-
import fs from 'fs'
|
|
2
|
-
import { rimraf } from 'rimraf'
|
|
1
|
+
import fs from 'fs/promises'
|
|
3
2
|
|
|
4
3
|
function move(from, to) {
|
|
5
|
-
return
|
|
6
|
-
fs.rename(from, to, (err) => {
|
|
7
|
-
if(err) return reject(err)
|
|
8
|
-
resolve(to)
|
|
9
|
-
})
|
|
10
|
-
})
|
|
4
|
+
return fs.rename(from, to)
|
|
11
5
|
}
|
|
12
6
|
|
|
13
7
|
function copy(from, to) {
|
|
14
|
-
return
|
|
15
|
-
fs.copyFile(from, to, (err) => {
|
|
16
|
-
if(err) return reject(err)
|
|
17
|
-
resolve(to)
|
|
18
|
-
})
|
|
19
|
-
})
|
|
8
|
+
return fs.copyFile(from, to)
|
|
20
9
|
}
|
|
21
10
|
|
|
22
11
|
function mkdir(name) {
|
|
23
|
-
return
|
|
24
|
-
fs.mkdir(name, { recursive: true }, (err) => {
|
|
25
|
-
if(err) return reject(err)
|
|
26
|
-
resolve(name)
|
|
27
|
-
})
|
|
28
|
-
})
|
|
12
|
+
return fs.mkdir(name, { recursive: true })
|
|
29
13
|
}
|
|
30
14
|
|
|
31
15
|
function rmdir(path) {
|
|
32
|
-
return
|
|
33
|
-
rimraf(path, (err) => {
|
|
34
|
-
if(err) return reject(err)
|
|
35
|
-
resolve(path)
|
|
36
|
-
})
|
|
37
|
-
})
|
|
16
|
+
return fs.rm(path, { recursive: true, force: true })
|
|
38
17
|
}
|
|
39
18
|
|
|
40
19
|
export { move, copy, mkdir, rmdir }
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@live-change/image-service",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.142",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -21,12 +21,12 @@
|
|
|
21
21
|
"url": "https://www.viamage.com/"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@live-change/framework": "^0.8.
|
|
25
|
-
"@live-change/relations-plugin": "^0.8.
|
|
24
|
+
"@live-change/framework": "^0.8.142",
|
|
25
|
+
"@live-change/relations-plugin": "^0.8.142",
|
|
26
26
|
"download": "^8.0.0",
|
|
27
27
|
"pluralize": "^8.0.0",
|
|
28
28
|
"sharp": "^0.32.5"
|
|
29
29
|
},
|
|
30
|
-
"gitHead": "
|
|
30
|
+
"gitHead": "6c6de9015268e09f3517dc2dbb28e673ea19fe74",
|
|
31
31
|
"type": "module"
|
|
32
32
|
}
|