Use utility.resolveFilePath() with utility.loadFile()

This commit is contained in:
Mohammad Fares 2018-10-14 21:38:38 +03:00
parent e2d44bd92c
commit 89cdebcf65
1 changed files with 2 additions and 9 deletions

View File

@ -69,18 +69,11 @@ function loadFile(filePath, extension) {
var content = null; var content = null;
// Resolve the path into an absolute path // Resolve the path into an absolute path
filePath = di.path.resolve(filePath); filePath = resolveFilePath(filePath, extension);
// The file doesn't exist // The file doesn't exist
if (!isFile(filePath)) { if (!isFile(filePath)) {
throw new Error('The provided file doesn\'t exit');
// A file with .yml suffix also doesn't exist
if (!isFile(filePath + '.' + extension)) {
throw new Error('The provided file doesn\'t exit');
} else {
filePath = filePath + '.yml';
}
} }
// Read the file // Read the file