From 08d62af89979b7e8e784a6dc4e010308796e35ed Mon Sep 17 00:00:00 2001 From: "Basile Trujilllo [L0gIn]" Date: Tue, 17 Oct 2017 10:33:16 +0200 Subject: [PATCH] Resolve file path before read file --- lib/classes/Variables.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/classes/Variables.js b/lib/classes/Variables.js index 7e8c0a888..6a99a6dd6 100644 --- a/lib/classes/Variables.js +++ b/lib/classes/Variables.js @@ -6,6 +6,7 @@ const replaceall = require('replaceall'); const logWarning = require('./Error').logWarning; const BbPromise = require('bluebird'); const os = require('os'); +const fse = require('../utils/fs/fse'); class Variables { @@ -230,9 +231,13 @@ class Variables { .replace(this.fileRefSyntax, (match, varName) => varName.trim()) .replace('~', os.homedir()); - const referencedFileFullPath = (path.isAbsolute(referencedFileRelativePath) ? + let referencedFileFullPath = (path.isAbsolute(referencedFileRelativePath) ? referencedFileRelativePath : path.join(this.serverless.config.servicePath, referencedFileRelativePath)); + + // Get real path to handle potential symlinks + referencedFileFullPath = fse.realpathSync(referencedFileFullPath, 'utf8'); + let fileExtension = referencedFileRelativePath.split('.'); fileExtension = fileExtension[fileExtension.length - 1]; // Validate file exists