@@ -2,8 +2,6 @@ import fs from 'fs';
2
2
import path from 'path' ;
3
3
4
4
import stripJSONComments from 'strip-json-comments' ;
5
- import isUTF8 from 'is-utf8' ;
6
- import stripBom from 'strip-bom' ;
7
5
8
6
import { getNormalizedConfig } from '../configLoader' ;
9
7
@@ -19,7 +17,7 @@ export default getConfigContent;
19
17
function readConfigContent ( configPath ) {
20
18
const parsedPath = path . parse ( configPath )
21
19
const isRcFile = parsedPath . ext !== '.js' && parsedPath . ext !== '.json' ;
22
- const jsonString = readConfigFileContent ( configPath ) ;
20
+ const jsonString = fs . readFileSync ( configPath , 'utf-8' ) ;
23
21
const parse = isRcFile ?
24
22
( contents ) => JSON . parse ( stripJSONComments ( contents ) ) :
25
23
( contents ) => JSON . parse ( contents ) ;
@@ -63,20 +61,3 @@ function getConfigContent (configPath, baseDirectory) {
63
61
const content = readConfigContent ( resolvedPath ) ;
64
62
return getNormalizedConfig ( configBasename , content ) ;
65
63
} ;
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