mirror of
https://github.com/serverless/serverless.git
synced 2026-01-18 14:58:43 +00:00
27 lines
813 B
JavaScript
27 lines
813 B
JavaScript
'use strict';
|
|
|
|
const path = require('path');
|
|
const os = require('os');
|
|
const BbPromise = require('bluebird');
|
|
const childProcess = BbPromise.promisifyAll(require('child_process'));
|
|
const fileExistsSync = require('../../../utils/fs/fileExistsSync');
|
|
|
|
function eventGatewayInstalled(eventGatewayVersion) {
|
|
const eventGatewayBinaryFilePath = path
|
|
.join(os.homedir(), '.serverless', 'event-gateway', 'event-gateway');
|
|
|
|
if (!fileExistsSync(eventGatewayBinaryFilePath)) {
|
|
return false;
|
|
}
|
|
|
|
const cp = childProcess.spawnSync(eventGatewayBinaryFilePath, ['--version'],
|
|
{ encoding: 'utf8' });
|
|
const currentVersion = cp.stdout.replace('Event Gateway version: ', '').trim();
|
|
if (currentVersion !== eventGatewayVersion) {
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
module.exports = eventGatewayInstalled;
|