This repository was archived by the owner on Dec 22, 2020. It is now read-only.
File tree 2 files changed +16
-2
lines changed
2 files changed +16
-2
lines changed Original file line number Diff line number Diff line change 2
2
MIT License http://www.opensource.org/licenses/mit-license.php
3
3
Author Tobias Koppers @sokra
4
4
*/
5
+
6
+ import util from 'util' ;
5
7
import JSON5 from 'json5' ;
6
8
7
9
function Json5Loader ( source ) {
@@ -13,7 +15,7 @@ function Json5Loader(source) {
13
15
throw new Error ( 'Error parsing JSON5' , ( e ) ) ;
14
16
}
15
17
16
- return `module.exports = ${ JSON . stringify ( value , null , '\t' ) } ` ;
18
+ return `module.exports = ${ util . inspect ( value , { depth : null } ) } ` ;
17
19
}
18
20
19
21
export default Json5Loader ;
Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ describe(PROJECT_NAME, () => {
11
11
12
12
test ( 'should convert to requires' , ( done ) => {
13
13
const content = Json5Loader . call ( { } , staticJson5 ) ;
14
- expect ( content ) . toBe ( 'module.exports = {\n\t" name": " test"\n }' ) ;
14
+ expect ( content ) . toBe ( 'module.exports = { name: \' test\' }' ) ;
15
15
done ( ) ;
16
16
} ) ;
17
17
@@ -22,4 +22,16 @@ describe(PROJECT_NAME, () => {
22
22
} ) . toThrow ( 'Error parsing JSON5' ) ;
23
23
done ( ) ;
24
24
} ) ;
25
+
26
+ test ( 'should preserve Infinity' , ( done ) => {
27
+ const content = Json5Loader . call ( { } , '{to : Infinity}' ) ;
28
+ expect ( content ) . toBe ( 'module.exports = { to: Infinity }' ) ;
29
+ done ( ) ;
30
+ } ) ;
31
+
32
+ test ( 'should preserve NaN' , ( done ) => {
33
+ const content = Json5Loader . call ( { } , '{nan : NaN}' ) ;
34
+ expect ( content ) . toBe ( 'module.exports = { nan: NaN }' ) ;
35
+ done ( ) ;
36
+ } ) ;
25
37
} ) ;
You can’t perform that action at this time.
0 commit comments