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;
// Resolve the path into an absolute path
filePath = di.path.resolve(filePath);
filePath = resolveFilePath(filePath, extension);
// The file doesn't exist
if (!isFile(filePath)) {
// 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';
}
throw new Error('The provided file doesn\'t exit');
}
// Read the file