firebase-ci
Version:
Simplified Firebase interaction for continuous integration including deploying hosting, functions, and database/storage rules.
41 lines (30 loc) • 1.14 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getFile = getFile;
exports.functionsExists = functionsExists;
exports.functionsNodeModulesExist = functionsNodeModulesExist;
var _chalk = _interopRequireDefault(require("chalk"));
var _fs = _interopRequireDefault(require("fs"));
var _path = _interopRequireDefault(require("path"));
var _logger = require("./logger");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function getFile(filePath) {
const localPath = _path.default.join(process.cwd(), filePath);
if (!_fs.default.existsSync(localPath)) {
return {};
}
try {
return JSON.parse(_fs.default.readFileSync(localPath, 'utf8'));
} catch (err) {
(0, _logger.error)(`Unable to parse ${_chalk.default.cyan(filePath)} - JSON is most likley not valid`);
throw err;
}
}
function functionsExists() {
return _fs.default.existsSync(_path.default.join(process.cwd(), 'functions'));
}
function functionsNodeModulesExist() {
return _fs.default.existsSync(_path.default.join(process.cwd(), 'functions', 'node_modules'));
}