Skip to content

Commit 4a805dc

Browse files
committedApr 27, 2021
format
1 parent 7c639f1 commit 4a805dc

File tree

2 files changed

+23
-19
lines changed

2 files changed

+23
-19
lines changed
 

‎src/tasks/prepare/index.mjs

+15-13
Original file line numberDiff line numberDiff line change
@@ -101,19 +101,21 @@ export const prepare = async (app, config) => {
101101
staticDirs = [staticDirs]
102102
}
103103

104-
await Promise.all(staticDirs.map(async dir => {
105-
const staticFiles = await fs.getFiles(dir)
106-
107-
if (!is.empty(staticFiles)) {
108-
const staticPromises = staticFiles.map(async f => {
109-
const name = f.replace(dir, '')
110-
// TODO: use streams here
111-
app.static[name] = await fs.readFile(f)
112-
})
113-
114-
await Promise.all(staticPromises)
115-
}
116-
}))
104+
await Promise.all(
105+
staticDirs.map(async dir => {
106+
const staticFiles = await fs.getFiles(dir)
107+
108+
if (!is.empty(staticFiles)) {
109+
const staticPromises = staticFiles.map(async f => {
110+
const name = f.replace(dir, '')
111+
// TODO: use streams here
112+
app.static[name] = await fs.readFile(f)
113+
})
114+
115+
await Promise.all(staticPromises)
116+
}
117+
}),
118+
)
117119
} catch (e) {
118120
// it's fine if the static dir does not exist,
119121
// but all other errors will throw.

‎src/tasks/transpile/html.mjs

+8-6
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,14 @@ export default ({ app, root }) => {
2222
tags.map(tag => {
2323
const urlsTangle = rendered.split(`${tag}="`)
2424

25-
const urls = urlsTangle.map(url => {
26-
url = url.split('"')[0]
27-
if (url.startsWith('/') && !url.startsWith(root)) {
28-
return [url, replaceSlashSlash(`${root}/${url}`)]
29-
}
30-
}).filter(a => a)
25+
const urls = urlsTangle
26+
.map(url => {
27+
url = url.split('"')[0]
28+
if (url.startsWith('/') && !url.startsWith(root)) {
29+
return [url, replaceSlashSlash(`${root}/${url}`)]
30+
}
31+
})
32+
.filter(a => a)
3133

3234
urls.forEach(([oldUrl, newUrl]) => {
3335
rendered = rendered.replace(new RegExp(`${tag}="${oldUrl}"`, 'gim'), `${tag}="${newUrl}"`)

0 commit comments

Comments
 (0)
Please sign in to comment.