serverless/lib/utils/fs/readFileIfExists.js
2019-05-29 13:34:27 +02:00

18 lines
390 B
JavaScript

'use strict';
const fileExists = require('./fileExists');
const readFile = require('./readFile');
const BbPromise = require('bluebird');
const readFileIfExists = function (filePath) {
return fileExists(filePath)
.then((exists) => {
if (!exists) {
return BbPromise.resolve(false);
}
return readFile(filePath);
});
};
module.exports = readFileIfExists;