Skip to content
This repository was archived by the owner on Nov 22, 2024. It is now read-only.

Commit c765bad

Browse files
committed
fix(hapi-engine): schematics compatible with IIS Node and Azure App service
The problem is that the `interceptor.js` which is used by IIS Node will require the application files rather than executing it. https://github.com/tjanczuk/iisnode/blob/8657944f8803d84514c0c7ddd48c046aa68e6edf/src/scripts/interceptor.js#L210 Thus, the server `run` method will never get invoked. Closes #1447
1 parent 681124b commit c765bad

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

integration/hapi-engine-ivy/server.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ async function run(): Promise<void> {
5858
// The below code is to ensure that the server is run only when not requiring the bundle.
5959
declare const __non_webpack_require__: NodeRequire;
6060
const mainModule = __non_webpack_require__.main;
61-
if (mainModule && mainModule.filename === __filename) {
61+
const moduleFilename = mainModule && mainModule.filename || '';
62+
if (moduleFilename === __filename || moduleFilename.includes('iisnode')) {
6263
run().catch(error => {
6364
console.error(`Error: ${error.toString()}`);
6465
process.exit(1);

integration/hapi-engine-ve/server.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ async function run(): Promise<void> {
5858
// The below code is to ensure that the server is run only when not requiring the bundle.
5959
declare const __non_webpack_require__: NodeRequire;
6060
const mainModule = __non_webpack_require__.main;
61-
if (mainModule && mainModule.filename === __filename) {
61+
const moduleFilename = mainModule && mainModule.filename || '';
62+
if (moduleFilename === __filename || moduleFilename.includes('iisnode')) {
6263
run().catch(error => {
6364
console.error(`Error: ${error.toString()}`);
6465
process.exit(1);

modules/hapi-engine/schematics/install/files/__serverFileName@stripTsExtension__.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ async function run(): Promise<void> {
5858
// The below code is to ensure that the server is run only when not requiring the bundle.
5959
declare const __non_webpack_require__: NodeRequire;
6060
const mainModule = __non_webpack_require__.main;
61-
if (mainModule && mainModule.filename === __filename) {
61+
const moduleFilename = mainModule && mainModule.filename || '';
62+
if (moduleFilename === __filename || moduleFilename.includes('iisnode')) {
6263
run().catch(error => {
6364
console.error(`Error: ${error.toString()}`);
6465
process.exit(1);

0 commit comments

Comments
 (0)