1
1
/* eslint-disable no-console */
2
2
import path from 'path' ;
3
- import { outputFile } from 'fs-extra' ;
4
3
import { Listr } from 'listr2' ;
5
4
import { get } from 'lodash' ;
6
5
import boxen from 'boxen' ;
@@ -25,9 +24,8 @@ import {
25
24
getBaselinePath ,
26
25
getBaselineRelativePath ,
27
26
getReportInfo ,
28
- readBaseline ,
29
27
readJSONStream ,
30
- writeBaseline ,
28
+ writeJSON ,
31
29
} from '@bundle-stats/cli-utils' ;
32
30
33
31
import LOCALES from './locales.json' ;
@@ -105,7 +103,7 @@ export default async function run(options: RunOptions): Promise<void> {
105
103
let baselineStats = { } ;
106
104
107
105
try {
108
- baselineStats = await readBaseline ( baselineAbsolutePath ) ;
106
+ baselineStats = await readJSONStream ( baselineAbsolutePath ) ;
109
107
ctx . baselineStats = baselineStats ;
110
108
} catch ( err ) {
111
109
return TEXT . BASELINE_MISSING ;
@@ -120,7 +118,7 @@ export default async function run(options: RunOptions): Promise<void> {
120
118
const stats = get ( ctx , 'sources[0]webpack' ) ;
121
119
const filteredWebpackStats = webpackFilter ( stats ) as Record < string , unknown > ;
122
120
123
- return writeBaseline ( baselineAbsolutePath , filteredWebpackStats ) . then ( ( ) => {
121
+ return writeJSON ( baselineAbsolutePath , filteredWebpackStats ) . then ( ( ) => {
124
122
// eslint-disable-next-line no-param-reassign
125
123
task . title = `${ task . title } (${ baselinePath } )` ;
126
124
} ) ;
@@ -148,7 +146,7 @@ export default async function run(options: RunOptions): Promise<void> {
148
146
title : filename ,
149
147
task : async ( ) => {
150
148
const filepath = path . join ( outDir , filename ) ;
151
- await outputFile ( filepath , output ) ;
149
+ await writeJSON ( filepath , output ) ;
152
150
153
151
ctx . output = [ ...( ctx . output ? ctx . output : [ ] ) , filepath ] ;
154
152
} ,
0 commit comments