@@ -2,8 +2,6 @@ import fs from 'fs';
22import path from 'path' ;
33
44import stripJSONComments from 'strip-json-comments' ;
5- import isUTF8 from 'is-utf8' ;
6- import stripBom from 'strip-bom' ;
75
86import { getNormalizedConfig } from '../configLoader' ;
97
@@ -19,7 +17,7 @@ export default getConfigContent;
1917function readConfigContent ( configPath ) {
2018 const parsedPath = path . parse ( configPath )
2119 const isRcFile = parsedPath . ext !== '.js' && parsedPath . ext !== '.json' ;
22- const jsonString = readConfigFileContent ( configPath ) ;
20+ const jsonString = fs . readFileSync ( configPath , 'utf-8' ) ;
2321 const parse = isRcFile ?
2422 ( contents ) => JSON . parse ( stripJSONComments ( contents ) ) :
2523 ( contents ) => JSON . parse ( contents ) ;
@@ -63,20 +61,3 @@ function getConfigContent (configPath, baseDirectory) {
6361 const content = readConfigContent ( resolvedPath ) ;
6462 return getNormalizedConfig ( configBasename , content ) ;
6563} ;
66-
67- /**
68- * Read proper content from config file.
69- * If the chartset of the config file is not utf-8, one error will be thrown.
70- * @param {String } configPath
71- * @return {String }
72- */
73- function readConfigFileContent ( configPath ) {
74-
75- let rawBufContent = fs . readFileSync ( configPath ) ;
76-
77- if ( ! isUTF8 ( rawBufContent ) ) {
78- throw new Error ( `The config file at "${ configPath } " contains invalid charset, expect utf8` ) ;
79- }
80-
81- return stripBom ( rawBufContent . toString ( "utf8" ) ) ;
82- }
0 commit comments