diff --git a/bin/stencil-start.js b/bin/stencil-start.js index d013551c..cff25ce7 100755 --- a/bin/stencil-start.js +++ b/bin/stencil-start.js @@ -75,7 +75,7 @@ try { } let browserSyncPort = dotStencilFile.port; -let stencilServerPort = ++dotStencilFile.port; +++dotStencilFile.port; if (!(dotStencilFile.normalStoreUrl) || !(dotStencilFile.customLayouts)) { console.error( 'Error: Your stencil config is outdated. Please run'.red + @@ -84,16 +84,19 @@ if (!(dotStencilFile.normalStoreUrl) || !(dotStencilFile.customLayouts)) { process.exit(2); } -runAPICheck(dotStencilFile, PACKAGE_INFO.version) - .then(storeInfoFromAPI => { +run(); + +async function run () { + try { + const storeInfoFromAPI = await runAPICheck(dotStencilFile, PACKAGE_INFO.version); dotStencilFile.storeUrl = storeInfoFromAPI.sslUrl; dotStencilFile.normalStoreUrl = storeInfoFromAPI.baseUrl; - dotStencilFile.stencilServerPort = stencilServerPort; - }) - .then(() => { - startServer(); - }) - .catch(err => console.error(err.message)); + + await startServer(); + } catch (err) { + console.error(err.message); + } +} /** * @@ -227,7 +230,7 @@ async function startServer() { ignoreInitial: true, ignored: watchIgnored.map(val => Path.join(THEME_PATH, val)), }, - proxy: "localhost:" + stencilServerPort, + proxy: "localhost:" + dotStencilFile.port, tunnel, }); diff --git a/server/plugins/renderer/renderer.module.js b/server/plugins/renderer/renderer.module.js index 81d4c3f5..8c9b3ec4 100644 --- a/server/plugins/renderer/renderer.module.js +++ b/server/plugins/renderer/renderer.module.js @@ -359,7 +359,7 @@ internals.getPencilResponse = function (data, request, response, configuration) data.context.settings.theme_version_id = utils.int2uuid(1); data.context.settings.theme_config_id = utils.int2uuid(request.app.themeConfig.variationIndex + 1); data.context.settings.theme_session_id = null; - data.context.settings.maintenance = {secure_path: `http://localhost:${internals.options.stencilServerPort}`}; + data.context.settings.maintenance = { secure_path: `http://localhost:${internals.options.port}` }; return new responses.PencilResponse({ template_file: internals.getTemplatePath(request.path, data),