From 37a122f4f4c021891445c5b6f9151f96c8edb6ce Mon Sep 17 00:00:00 2001 From: Jaakko Juvonen Date: Mon, 2 Sep 2024 11:56:40 +0300 Subject: [PATCH] Add missing promisify to fs module functions. Fixes #1912. --- lib/packageModules.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/packageModules.js b/lib/packageModules.js index 650a3cf24..7fffcdf97 100644 --- a/lib/packageModules.js +++ b/lib/packageModules.js @@ -9,6 +9,9 @@ const semver = require('semver'); const fs = require('fs'); const { getAllNodeFunctions, isProviderGoogle } = require('./utils'); +const readFileAsync = BbPromise.promisify(fs.readFile); +const statAsync = BbPromise.promisify(fs.stat); + function setArtifactPath(funcName, func, artifactPath) { const version = this.serverless.getVersion(); @@ -90,8 +93,8 @@ function getFileContentAndStat(directory, filePath) { return BbPromise.all([ // Get file contents and stat in parallel - fs.readFileAsync(fullPath), - fs.statAsync(fullPath) + readFileAsync(fullPath), + statAsync(fullPath) ]).then( result => ({ data: result[0],