File tree 6 files changed +66
-16
lines changed
6 files changed +66
-16
lines changed Original file line number Diff line number Diff line change @@ -20,9 +20,15 @@ TypeScriptLoaderSync();
20
20
21
21
console . info ( "Loaded with CJS successfully" ) ;
22
22
} catch ( error ) {
23
- console . error ( error ) ;
24
- console . debug ( error . stack ) ;
25
- console . error ( "Failed to load with CJS" ) ;
23
+ console . error ( "Failed to load configuration with CJS" ) ;
24
+ if ( error instanceof TypeError ) {
25
+ console . error ( "Type error occurred:" , error . message ) ;
26
+ } else if ( error instanceof SyntaxError ) {
27
+ console . error ( "Syntax error in configuration file:" , error . message ) ;
28
+ } else {
29
+ console . error ( "An unexpected error occurred:" , error . message ) ;
30
+ }
31
+ console . debug ( "Error stack trace:" , error . stack ) ;
26
32
process . exit ( 1 ) ;
27
33
}
28
34
} ) ( ) ;
Original file line number Diff line number Diff line change @@ -20,9 +20,15 @@ TypeScriptLoader();
20
20
21
21
console . info ( "Loaded with CJS successfully" ) ;
22
22
} catch ( error ) {
23
- console . error ( error ) ;
24
- console . debug ( error . stack ) ;
25
- console . error ( "Failed to load with CJS" ) ;
23
+ console . error ( "Failed to load configuration with CJS" ) ;
24
+ if ( error instanceof TypeError ) {
25
+ console . error ( "Type error occurred:" , error . message ) ;
26
+ } else if ( error instanceof SyntaxError ) {
27
+ console . error ( "Syntax error in configuration file:" , error . message ) ;
28
+ } else {
29
+ console . error ( "An unexpected error occurred:" , error . message ) ;
30
+ }
31
+ console . debug ( "Error stack trace:" , error . stack ) ;
26
32
process . exit ( 1 ) ;
27
33
}
28
34
} ) ( ) ;
Original file line number Diff line number Diff line change @@ -20,9 +20,15 @@ TypeScriptLoaderSync();
20
20
21
21
console . info ( "Loaded with ESM successfully" ) ;
22
22
} catch ( error ) {
23
- console . error ( error ) ;
24
- console . debug ( error . stack ) ;
25
- console . error ( "Failed to load with ESM" ) ;
23
+ console . error ( "Failed to load configuration with ESM" ) ;
24
+ if ( error instanceof TypeError ) {
25
+ console . error ( "Type error occurred:" , error . message ) ;
26
+ } else if ( error instanceof SyntaxError ) {
27
+ console . error ( "Syntax error in configuration file:" , error . message ) ;
28
+ } else {
29
+ console . error ( "An unexpected error occurred:" , error . message ) ;
30
+ }
31
+ console . debug ( "Error stack trace:" , error . stack ) ;
26
32
process . exit ( 1 ) ;
27
33
}
28
34
} ) ( ) ;
Original file line number Diff line number Diff line change @@ -20,9 +20,15 @@ TypeScriptLoader();
20
20
21
21
console . info ( "Loaded with ESM successfully" ) ;
22
22
} catch ( error ) {
23
- console . error ( error ) ;
24
- console . debug ( error . stack ) ;
25
- console . error ( "Failed to load with ESM" ) ;
23
+ console . error ( "Failed to load configuration with ESM" ) ;
24
+ if ( error instanceof TypeError ) {
25
+ console . error ( "Type error occurred:" , error . message ) ;
26
+ } else if ( error instanceof SyntaxError ) {
27
+ console . error ( "Syntax error in configuration file:" , error . message ) ;
28
+ } else {
29
+ console . error ( "An unexpected error occurred:" , error . message ) ;
30
+ }
31
+ console . debug ( "Error stack trace:" , error . stack ) ;
26
32
process . exit ( 1 ) ;
27
33
}
28
34
} ) ( ) ;
Original file line number Diff line number Diff line change @@ -12,8 +12,19 @@ const assert = require("node:assert");
12
12
assert . strictEqual ( typeof cjs === "function" , true ) ;
13
13
14
14
// Try to create loaders
15
- esm ( ) ;
16
- cjs ( ) ;
15
+ const esmResult = esm ( { } ) ;
16
+ const cjsResult = cjs ( { } ) ;
17
+
18
+ assert . strictEqual (
19
+ typeof esmResult ,
20
+ "function" ,
21
+ "ESM loader should return an function" ,
22
+ ) ;
23
+ assert . strictEqual (
24
+ typeof cjsResult ,
25
+ "function" ,
26
+ "CJS loader should return an function" ,
27
+ ) ;
17
28
18
29
console . info ( "Loaded with both CJS and ESM successfully" ) ;
19
30
} catch ( error ) {
Original file line number Diff line number Diff line change @@ -12,8 +12,23 @@ const assert = require("node:assert");
12
12
assert . strictEqual ( typeof cjs === "function" , true ) ;
13
13
14
14
// Try to create loaders
15
- esm ( ) ;
16
- cjs ( ) ;
15
+ const esmResult = await esm ( {
16
+ /* mock config */
17
+ } ) ;
18
+ const cjsResult = await cjs ( {
19
+ /* mock config */
20
+ } ) ;
21
+
22
+ assert . strictEqual (
23
+ typeof esmResult ,
24
+ "function" ,
25
+ "ESM loader should return an function" ,
26
+ ) ;
27
+ assert . strictEqual (
28
+ typeof cjsResult ,
29
+ "function" ,
30
+ "CJS loader should return an function" ,
31
+ ) ;
17
32
18
33
console . info ( "Loaded with both CJS and ESM successfully" ) ;
19
34
} catch ( error ) {
You can’t perform that action at this time.
0 commit comments