UNPKG

@sap/cds-dk

Version:

Command line client and development toolkit for the SAP Cloud Application Programming Model

43 lines (35 loc) 1.54 kB
// // Child process impl launched by cds watch // Extracted from watch.js to avoid cds.env loaded too eagerly // (async () => { // run through cli in order to use its error handling const args = JSON.parse(process.env._args) const cds = require('../cds'); cds.watched = true const bootstrap = require('../../bin/cds')(...args) cds.once('listening', async ({ server }) => { process.send({ code: 'listening', port: server.address().port }) if (process.env.CDS_WATCH_HOT_RELOAD && process.env.CDS_WATCH_HOT_RELOAD !== 'false') { const hotReload = require('./hot-reload'); await hotReload() } }) try { await bootstrap if (cds.service.providers.length === 0) return _no_services_found() } catch (e) { switch (e.code) { case 'NO_SERVICES_FOUND': return _no_services_found(e) case 'MODEL_NOT_FOUND': return _no_models_found(e) case 'EADDRINUSE': return process.send(e) //> tell cds watch default: if (e.messages?.length) return cds._log(e.messages, { 'log-level': cds.env.log.levels.cli }) // REVISIT: no special handling for compiler messages else console.error('\n❗️ ERROR on server start: ❗️\n\n', e) }} function _no_models_found(e) { console.log (` No models found in ${(e.files||cds.resolve(e.model||'*',false)).filter(f => !(f in {schema:1,services:2}))}. Waiting for some to arrive... `)} function _no_services_found() { console.log (` No service definitions found in loaded models. Waiting for some to arrive... `)} })()