File tree Expand file tree Collapse file tree 4 files changed +26
-1
lines changed Expand file tree Collapse file tree 4 files changed +26
-1
lines changed Original file line number Diff line number Diff line change 15411541 "execa" : " 5.1.1" ,
15421542 "fs-extra" : " 10.1.0" ,
15431543 "js-yaml" : " 4.1.0" ,
1544+ "json5" : " ^2.2.1" ,
15441545 "lodash.clonedeep" : " 4.5.0" ,
15451546 "lodash.get" : " 4.4.2" ,
15461547 "lodash.isempty" : " 4.4.0" ,
Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ import { getOptions } from './options'
1919import { typeCheckCommands } from '..'
2020import { MaybeConsoleError } from '../error'
2121import { Logger } from '../../common/logger'
22+ import { parseNonStandardJson } from '../../util/json'
2223
2324const defaultExperimentsOutput : ExperimentsOutput = {
2425 workspace : { baseline : { } }
@@ -122,7 +123,7 @@ export class DvcReader extends DvcCli {
122123 try {
123124 const output =
124125 ( await this . executeDvcProcess ( cwd , ...args ) ) || defaultValue
125- return JSON . parse ( output ) as T
126+ return parseNonStandardJson ( output ) as T
126127 } catch ( error : unknown ) {
127128 const msg =
128129 ( error as MaybeConsoleError ) . stderr || ( error as Error ) . message
Original file line number Diff line number Diff line change 1+ import { parseNonStandardJson } from './json'
2+
3+ describe ( 'parseNonStandardJson' , ( ) => {
4+ it ( 'should parse NaN' , ( ) => {
5+ expect ( parseNonStandardJson ( '{NotANumber:NaN}' ) ) . toStrictEqual ( {
6+ NotANumber : Number . NaN
7+ } )
8+ } )
9+
10+ it ( 'should parse Infinity' , ( ) => {
11+ expect (
12+ parseNonStandardJson (
13+ '{negativeInfinity:-Infinity, positiveInfinity: Infinity}'
14+ )
15+ ) . toStrictEqual ( {
16+ negativeInfinity : Number . NEGATIVE_INFINITY ,
17+ positiveInfinity : Number . POSITIVE_INFINITY
18+ } )
19+ } )
20+ } )
Original file line number Diff line number Diff line change 1+ import JSON5 from 'json5'
2+
3+ export const parseNonStandardJson = ( str : string ) => JSON5 . parse ( str )
You can’t perform that action at this time.
0 commit comments