@@ -39,6 +39,7 @@ function runCommand(command, args, options = {}) {
3939 proc . on ( 'close' , ( code ) => {
4040 if ( rejectedOrResolved ) return ;
4141 if ( timeoutId ) clearTimeout ( timeoutId ) ;
42+ console . log ( `Process exited with code ${ code } ` ) ;
4243 if ( code === 0 || code === 255 ) {
4344 setTimeout ( ( ) => resolve ( { stdout, stderr, code } ) , 5000 ) ;
4445 } else {
@@ -116,12 +117,12 @@ function runCommandWithTimeout(command, args, options = {}) {
116117 if ( options . verbose ) {
117118 console . log ( 'STDOUT:' , str . trim ( ) ) ;
118119 }
119-
120+
120121 // Call custom stdout handler if provided
121122 if ( options . onStdout ) {
122123 options . onStdout ( str , shutDown ) ;
123124 }
124-
125+
125126 // Default behavior: shutdown on final message
126127 if ( ! options . onStdout && options . finalMessage && str . match ( options . finalMessage ) && ! closed && ! resolvedOrRejected ) {
127128 console . log ( 'Final message detected, shutting down...' ) ;
@@ -196,7 +197,8 @@ async function createTestAdapter(configFile, targetDir) {
196197 '@iobroker/create-adapter@latest' ,
197198 `--replay=${ configPath } ` ,
198199 `--target=${ targetDir } ` ,
199- '--noInstall' // Skip npm install to speed up creation
200+ '--noInstall' , // Skip npm install to speed up creation
201+ '--nonInteractive' // Run in non-interactive mode to fill in missing config details
200202 ] , {
201203 cwd : targetDir ,
202204 timeout : 180000 , // 3 minutes
@@ -250,7 +252,7 @@ async function setupTestAdapter(config) {
250252
251253 // Install dependencies
252254 await installAdapterDependencies ( adapterName , adapterDir ) ;
253-
255+
254256 console . log ( `${ adapterName } test adapter prepared successfully` ) ;
255257}
256258
@@ -260,7 +262,7 @@ async function setupTestAdapter(config) {
260262async function applyTypeScriptPatches ( adapterDir ) {
261263 const mainTsPath = path . join ( adapterDir , 'src' , 'main.ts' ) ;
262264 let mainTsContent = fs . readFileSync ( mainTsPath , 'utf8' ) ;
263-
265+
264266 // Patch variable declarations for TypeScript compliance
265267 mainTsContent = mainTsContent . replace (
266268 'let result = await this.checkPasswordAsync("admin", "iobroker");' ,
@@ -274,7 +276,7 @@ async function applyTypeScriptPatches(adapterDir) {
274276 'this.log.info("check group user admin group admin: " + result);' ,
275277 'this.log.info("check group user admin group admin: " + groupResult);' ,
276278 ) ;
277-
279+
278280 fs . writeFileSync ( mainTsPath , mainTsContent , 'utf8' ) ;
279281 console . log ( `Patched ${ mainTsPath } for TypeScript compliance` ) ;
280282}
@@ -314,7 +316,7 @@ function cleanupTestAdapter(adapterName, adapterDir) {
314316function validateIoPackageJson ( adapterDir , expectedName , shouldHaveTypescript = false ) {
315317 const ioPackagePath = path . join ( adapterDir , 'io-package.json' ) ;
316318 const assert = require ( 'node:assert' ) ;
317-
319+
318320 assert . ok ( fs . existsSync ( ioPackagePath ) , 'io-package.json not found' ) ;
319321
320322 const ioPackage = JSON . parse ( fs . readFileSync ( ioPackagePath , 'utf8' ) ) ;
@@ -328,18 +330,18 @@ function validateIoPackageJson(adapterDir, expectedName, shouldHaveTypescript =
328330}
329331
330332/**
331- * Common assertions for package.json validation
333+ * Common assertions for package.json validation
332334 */
333335function validatePackageJson ( adapterDir ) {
334336 const packagePath = path . join ( adapterDir , 'package.json' ) ;
335337 const assert = require ( 'node:assert' ) ;
336-
338+
337339 assert . ok ( fs . existsSync ( packagePath ) , 'package.json not found' ) ;
338340
339341 const packageJson = JSON . parse ( fs . readFileSync ( packagePath , 'utf8' ) ) ;
340342 assert . ok ( packageJson . name , 'package.json missing name' ) ;
341343 assert . ok ( packageJson . version , 'package.json missing version' ) ;
342-
344+
343345 return packageJson ;
344346}
345347
@@ -349,7 +351,7 @@ function validatePackageJson(adapterDir) {
349351function validateTypeScriptConfig ( adapterDir ) {
350352 const tsconfigPath = path . join ( adapterDir , 'tsconfig.json' ) ;
351353 const assert = require ( 'node:assert' ) ;
352-
354+
353355 assert . ok ( fs . existsSync ( tsconfigPath ) , 'tsconfig.json not found for TypeScript adapter' ) ;
354356}
355357
@@ -461,7 +463,7 @@ function runCommandWithFileChange(command, args, options = {}) {
461463 if ( ! fileChanged && options . initialMessage && str . match ( options . initialMessage ) ) {
462464 console . log ( 'Initial message detected, triggering file change...' ) ;
463465 fileChanged = true ;
464-
466+
465467 // Wait a bit then trigger file change
466468 setTimeout ( ( ) => {
467469 if ( options . fileToChange ) {
@@ -476,13 +478,13 @@ function runCommandWithFileChange(command, args, options = {}) {
476478 }
477479 } , 5000 ) ;
478480 }
479-
481+
480482 // Detect restart and wait for it to complete
481483 if ( fileChanged && ! restartDetected && str . match ( / r e s t a r t i n g | r e s t a r t / i) ) {
482484 console . log ( 'Restart detected...' ) ;
483485 restartDetected = true ;
484486 }
485-
487+
486488 // After restart, wait for final message
487489 if ( restartDetected && options . finalMessage && str . match ( options . finalMessage ) ) {
488490 console . log ( 'Final message after restart detected, shutting down...' ) ;
0 commit comments