@based/cli
Advanced tools
Comparing version 5.9.1-alpha to 5.9.1-alpha2
@@ -1,2 +0,1 @@ | ||
/// <reference types="node" /> | ||
import http from 'http'; | ||
@@ -3,0 +2,0 @@ declare const _default: (port: number) => http.Server<typeof http.IncomingMessage, typeof http.ServerResponse>; |
@@ -197,2 +197,3 @@ "use strict"; | ||
const config = files.find(utils_2.isConfigFile); | ||
let configObj; | ||
if (!index) { | ||
@@ -208,10 +209,39 @@ throw new Error('no index file found'); | ||
sourcemap: 'external', | ||
}, async ({ outputFiles }) => { | ||
}, async ({ outputFiles, errors }) => { | ||
if (errors.length) { | ||
if (configObj) { | ||
server.functions.add({ | ||
[configObj.name]: { | ||
async fn() { | ||
return getErrorHtml(errors, lrPort); | ||
}, | ||
uninstallAfterIdleTime: -1, | ||
closeAfterIdleTime: 5e3, | ||
...DEFAULTS.function, | ||
...configObj, | ||
type: 'function', | ||
}, | ||
}); | ||
} | ||
else { | ||
console.error(errors); | ||
} | ||
return; | ||
} | ||
const config = outputFiles.find(({ path }) => (0, path_1.basename)(path) === 'based.config.js'); | ||
const fn = outputFiles.find(({ path }) => (0, path_1.basename)(path) === 'index.js'); | ||
const sourcemap = outputFiles.find(({ path }) => (0, path_1.basename)(path) === 'index.js.map'); | ||
let configObj = (0, utils_1.requireFromString)(config.text, config.path); | ||
configObj = (0, utils_1.requireFromString)(config.text, config.path); | ||
configObj = configObj.default || configObj; | ||
if (configObj.type === 'app' && configObj.main) { | ||
const r = (0, utils_1.requireFromString)(fn.text, fn.path); | ||
let r; | ||
try { | ||
r = (0, utils_1.requireFromString)(fn.text, fn.path); | ||
} | ||
catch (e) { | ||
r = () => { | ||
throw e; | ||
}; | ||
console.error(e); | ||
} | ||
const fnDefault = r.default || r; | ||
@@ -218,0 +248,0 @@ const opts = { |
{ | ||
"name": "@based/cli", | ||
"version": "5.9.1-alpha", | ||
"version": "5.9.1-alpha2", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "bin": "bin/cmd.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
238969
3598