Skip to content
This repository has been archived by the owner on May 22, 2024. It is now read-only.

Commit

Permalink
refactor: replace lstat with stat
Browse files Browse the repository at this point in the history
  • Loading branch information
eduardoboucas committed Oct 14, 2021
1 parent e81ce04 commit bacf899
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 3 additions & 1 deletion src/utils/fs.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
const { lstat, readdir, readFile, unlink, writeFile } = require('fs')
const { lstat, readdir, readFile, stat, unlink, writeFile } = require('fs')
const { format, join, parse, resolve } = require('path')
const { promisify } = require('util')

const pLstat = promisify(lstat)
const pReaddir = promisify(readdir)
const pReadFile = promisify(readFile)
const pStat = promisify(stat)
const pUnlink = promisify(unlink)
const pWriteFile = promisify(writeFile)

Expand Down Expand Up @@ -84,5 +85,6 @@ module.exports = {
listFunctionsDirectory,
resolveFunctionsDirectories,
safeUnlink,
stat: pStat,
writeFile: pWriteFile,
}
8 changes: 4 additions & 4 deletions src/zip.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const { createManifest } = require('./manifest')
const { getFunctionsFromPaths } = require('./runtimes')
const { getPluginsModulesPath } = require('./runtimes/node/utils/plugin_modules_path')
const { ARCHIVE_FORMAT_NONE, ARCHIVE_FORMAT_ZIP } = require('./utils/consts')
const { listFunctionsDirectories, lstat, resolveFunctionsDirectories } = require('./utils/fs')
const { listFunctionsDirectories, resolveFunctionsDirectories, stat } = require('./utils/fs')
const { removeFalsy } = require('./utils/remove_falsy')

const DEFAULT_PARALLEL_LIMIT = 5
Expand All @@ -22,7 +22,7 @@ const addArchiveSize = async (result) => {
return result
}

const { size } = await lstat(path)
const { size } = await stat(path)

return { ...result, size }
}
Expand Down Expand Up @@ -158,7 +158,7 @@ const zipFunction = async function (
return
}

const { config, extension, filename, mainFile, name, runtime, srcDir, stat } = functions.values().next().value
const { config, extension, filename, mainFile, name, runtime, srcDir, stat: stats } = functions.values().next().value
const pluginsModulesPath =
defaultModulesPath === undefined ? await getPluginsModulesPath(srcPath) : defaultModulesPath

Expand All @@ -178,7 +178,7 @@ const zipFunction = async function (
runtime,
srcDir,
srcPath,
stat,
stat: stats,
})

return formatZipResult({ ...zipResult, mainFile, name, runtime })
Expand Down

0 comments on commit bacf899

Please sign in to comment.