mirror of
https://github.com/serverless/serverless.git
synced 2026-01-25 15:07:39 +00:00
22 lines
552 B
JavaScript
22 lines
552 B
JavaScript
'use strict';
|
|
|
|
const fetch = require('node-fetch');
|
|
const BbPromise = require('bluebird');
|
|
|
|
function localEmulatorRunning() {
|
|
const localEmulatorPingEndpoint = 'http://localhost:8080/ping';
|
|
|
|
return fetch(localEmulatorPingEndpoint, {
|
|
method: 'GET',
|
|
timeout: 1000,
|
|
}).then(res => res.json())
|
|
.then(json => {
|
|
if (json.id === 'serverless-local-emulator') {
|
|
return BbPromise.resolve(true);
|
|
}
|
|
return BbPromise.resolve(false);
|
|
}).catch(() => BbPromise.resolve(false));
|
|
}
|
|
|
|
module.exports = localEmulatorRunning;
|