Remember to close file handle [skip ci]

This commit is contained in:
Isiah Meadows 2019-07-29 15:13:28 -04:00
parent 0d10dc2c89
commit 615a9364f0

View file

@ -140,6 +140,7 @@ async function generate() {
async function generate(file) { async function generate(file) {
try { try {
const handle = await fs.open(file, "r") const handle = await fs.open(file, "r")
try {
const relative = path.relative(r("docs"), file) const relative = path.relative(r("docs"), file)
const archive = r(`dist/archive/v${version}/${relative}`) const archive = r(`dist/archive/v${version}/${relative}`)
await fs.mkdir(path.dirname(archive), {recursive: true}) await fs.mkdir(path.dirname(archive), {recursive: true})
@ -158,6 +159,9 @@ async function generate() {
createWriteStream(archive) createWriteStream(archive)
) )
} }
} finally {
handle.close()
}
} catch (e) { } catch (e) {
if (e.code !== "EISDIR") throw e if (e.code !== "EISDIR") throw e
const files = await fs.readdir(file) const files = await fs.readdir(file)