Skip to content

Commit b6608fc

Browse files
committed
CHG: node: sort node/fs/File.js usage
1 parent 6259899 commit b6608fc

18 files changed

+79
-77
lines changed

source-bin/function.js

+10-8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { resolve, basename } from 'path'
2-
import { readFileSync, writeFileSync } from 'fs'
32
import { STAT_ERROR, getPathLstat } from '@dr-js/core/module/node/fs/Path.js'
3+
import { editTextSync, readJSONSync, writeJSONPrettySync } from '@dr-js/core/module/node/fs/File.js'
44
import { getFileList } from '@dr-js/core/module/node/fs/Directory.js'
55
import { modifyCopy, modifyDeleteForce } from '@dr-js/core/module/node/fs/Modify.js'
66

@@ -21,14 +21,14 @@ const writePackExportInitJSON = async ({
2121
fromPackExport = getFromPackExport(pathPackage)
2222
}) => {
2323
const initFilePrefix = fromPackExport('INIT#')
24-
writeFileSync(
24+
writeJSONPrettySync(
2525
fromPackExport(NAME_PACK_EXPORT_INIT_JSON),
26-
JSON.stringify((await getFileList(fromPackExport()))
26+
(await getFileList(fromPackExport()))
2727
.filter((path) => path.startsWith(initFilePrefix))
2828
.map((path) => [
2929
basename(path), // relative source
3030
path.slice(initFilePrefix.length).replace(/#/g, '/') // relative output
31-
]), null, 2)
31+
])
3232
)
3333
}
3434

@@ -38,7 +38,7 @@ const loadAndCopyPackExportInitJSON = async ({
3838
isReset = false
3939
}) => {
4040
const fromPackExport = getFromPackExport(pathPackage)
41-
const initPairList = JSON.parse(String(readFileSync(fromPackExport(NAME_PACK_EXPORT_INIT_JSON)))) // get init list
41+
const initPairList = readJSONSync(fromPackExport(NAME_PACK_EXPORT_INIT_JSON)) // get init list
4242

4343
if (!isReset) { // check if file overwrite will happen
4444
for (const [ , relativeInitPath ] of initPairList) {
@@ -52,9 +52,11 @@ const loadAndCopyPackExportInitJSON = async ({
5252
await modifyDeleteForce(initPath)
5353
await modifyCopy(sourcePath, initPath)
5454
// update file content
55-
REGEXP_TEXT_FILE.test(relativeInitPath) && writeFileSync(initPath, String(readFileSync(initPath))
56-
.replace(/\{FLAVOR}/g, /@dr-js[/\\]dev-([\w-]+)$/.exec(pathPackage)[ 1 ])
57-
.replace(/\{FLAVOR-VERSION}/g, JSON.parse(String(readFileSync(resolve(pathPackage, 'package.json')))).version)
55+
REGEXP_TEXT_FILE.test(relativeInitPath) && editTextSync(
56+
(string) => string
57+
.replace(/{FLAVOR}/g, /@dr-js[/\\]dev-([\w-]+)$/.exec(pathPackage)[ 1 ])
58+
.replace(/{FLAVOR-VERSION}/g, readJSONSync(resolve(pathPackage, 'package.json')).version)
59+
, initPath
5860
)
5961
console.log(`[init] file: ${relativeInitPath}`)
6062
}

source-bin/index.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
#!/usr/bin/env node
22

3-
import { readFileSync } from 'fs'
4-
53
import { doCheckOutdated } from './mode/checkOutdated.js'
64
import { doStepPackageVersion } from './mode/stepPackageVersion.js'
75
import { doTest } from './mode/test.js'
@@ -12,6 +10,7 @@ import { doVersionBump, getCommonVersionBump } from './mode/versionBump.js'
1210
import { doShellAlias } from './mode/shellAlias.js'
1311

1412
import { versionBumpByGitBranch, versionBumpLastNumber, versionBumpToIdentifier, versionBumpToLocal } from '@dr-js/core/module/common/module/SemVer.js'
13+
import { readJSONSync } from '@dr-js/core/module/node/fs/File.js'
1514
import { getGitBranch } from '@dr-js/core/module/node/module/Software/git.js'
1615
import { run } from '@dr-js/core/module/node/run.js'
1716
import { patchModulePath as patchModulePathCore, sharedOption, sharedMode } from '@dr-js/core/bin/function.js'
@@ -70,7 +69,7 @@ const runMode = async (optionData, modeName) => {
7069
case 'parse-script-list':
7170
case 'run-script':
7271
case 'run-script-list': {
73-
const packageJSON = JSON.parse(String(readFileSync('package.json'))) // TODO: NOTE: relative to cwd
72+
const packageJSON = readJSONSync('package.json') // TODO: NOTE: relative to cwd
7473
let command
7574
if (modeName.endsWith('-list')) {
7675
command = warpBashSubShell(argumentList

source-bin/mode/init.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { resolve } from 'path'
2-
import { readFileSync } from 'fs'
32

43
import { catchAsync } from '@dr-js/core/module/common/error.js'
54
import { indentLine } from '@dr-js/core/module/common/string.js'
5+
import { readTextSync } from '@dr-js/core/module/node/fs/File.js'
66
import { getFileList } from '@dr-js/core/module/node/fs/Directory.js'
77

88
import { findPathFragList } from 'source/node/file.js'
@@ -60,7 +60,7 @@ const initVerify = async (pathRoot, VERIFY_RULE_LIST) => {
6060
__DEV__ && console.log(` - selectPath: ${selectPath}`)
6161
for (const file of fileList) {
6262
__DEV__ && console.log(` - file: ${file}`)
63-
const fileString = String(readFileSync(file))
63+
const fileString = readTextSync(file)
6464
for (const { messageList, selectFilterFile, verifyFunc } of ruleList) {
6565
if (!selectFilterFile(file)) continue // filtered
6666
__DEV__ && console.log(` - check: ${messageList.join(' ')}`)

source-bin/mode/shellAlias.js

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
import { readFileSync, existsSync } from 'fs'
1+
import { existsSync } from 'fs'
22
import { hostname } from 'os'
33

44
import { describe } from '@dr-js/core/module/common/format.js'
55
import { isBasicArray, isBasicFunction, isBasicObject, isString } from '@dr-js/core/module/common/check.js'
66
import { getUTCDateTag } from '@dr-js/core/module/common/time.js'
77
import { expandHome } from '@dr-js/core/module/node/fs/Path.js'
8+
import { readTextSync, readJSONSync } from '@dr-js/core/module/node/fs/File.js'
89
import { resolveCommand } from '@dr-js/core/module/node/system/ResolveCommand.js'
910
import { runSync, runStdoutSync } from '@dr-js/core/module/node/run.js'
1011

@@ -68,7 +69,7 @@ const IS_ANDROID_TERMUX = (process.env.PREFIX || '').includes('com.termux') // t
6869
const GET_LINUX_PACKAGE_MANAGER = () => { // LSB linux: https://serverfault.com/questions/879216/how-to-detect-linux-distribution-and-version/880087#880087
6970
if (cacheLinuxPackageManage === undefined) {
7071
const nameLinuxRelease = IS_ANDROID_TERMUX ? 'Android (Termux)'
71-
: (existsSync('/etc/os-release') && (/\s"?NAME"?="?([\w/)( ]+)"?/.exec(String(readFileSync('/etc/os-release'))) || [])[ 1 ]) || 'non-LSB'
72+
: (existsSync('/etc/os-release') && (/\s"?NAME"?="?([\w/)( ]+)"?/.exec(readTextSync('/etc/os-release')) || [])[ 1 ]) || 'non-LSB'
7273
cacheLinuxPackageManage = [ 'Arch Linux', 'Arch Linux ARM' ].includes(nameLinuxRelease) ? 'pacman'
7374
: [ 'Ubuntu', 'Debian GNU/Linux', 'Raspbian GNU/Linux', 'Android (Termux)' ].includes(nameLinuxRelease) ? 'apt'
7475
: 'unknown'
@@ -360,11 +361,11 @@ const SHELL_ALIAS_LIST = {
360361
'quick-sudo-bash': 'sudo bash',
361362
'quick-git-diff': 'git diff --no-index --', // $1=old $2=new
362363
'quick-git-tag-push': () => {
363-
const TAG = `v${JSON.parse(String(readFileSync('package.json'))).version}`
364+
const TAG = `v${readJSONSync('package.json').version}`
364365
return _E([ 'git', 'tag', TAG ], [ 'git', 'push', 'origin', TAG ])
365366
},
366367
'quick-git-tag-push-force': () => {
367-
const TAG = `v${JSON.parse(String(readFileSync('package.json'))).version}`
368+
const TAG = `v${readJSONSync('package.json').version}`
368369
return _E([ 'git', 'tag', '--force', TAG ], [ 'git', 'push', 'origin', '--force', TAG ])
369370
},
370371
'quick-git-push-combo': _AE('git-push', 'quick-git-tag-push'),

source/license.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { writeFileSync } from 'fs'
1+
import { writeTextSync } from '@dr-js/core/module/node/fs/File.js'
22

33
const getLicenseMIT = (author) => `MIT License
44
@@ -33,7 +33,7 @@ const writeLicenseFile = (path, licenseType, licenseAuthor) => {
3333
if (!licenseAuthor) throw new Error(`invalid License author "${licenseAuthor}"`)
3434
const getLicense = GET_LICENSE_MAP[ licenseType.toUpperCase() ]
3535
if (!getLicense) throw new Error(`License type "${licenseType}" is not yet supported`)
36-
writeFileSync(path, getLicense(licenseAuthor))
36+
writeTextSync(path, getLicense(licenseAuthor))
3737
}
3838

3939
export { writeLicenseFile }

source/node/cache/checksum.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { dirname } from 'path'
2-
import { promises as fsAsync } from 'fs'
32

43
import { calcHash } from '@dr-js/core/module/node/data/Buffer.js'
4+
import { readBuffer, writeText } from '@dr-js/core/module/node/fs/File.js'
55
import { createDirectory } from '@dr-js/core/module/node/fs/Directory.js'
66
import {
77
getChecksumInfoOfFile,
@@ -39,7 +39,7 @@ const checksumUpdate = async (config, isChecksumFileOnly = false) => { // set is
3939
// save checksum file
4040
const checksumString = await describeChecksumOfPathList({ pathList: config.pathChecksumList })
4141
await createDirectory(dirname(config.pathChecksumFile))
42-
await fsAsync.writeFile(config.pathChecksumFile, checksumString)
42+
await writeText(config.pathChecksumFile, checksumString)
4343

4444
// detect hash change, but do not update
4545
const checksumHash = calcHash(checksumString, 'sha256')
@@ -57,7 +57,7 @@ const checksumDetectChange = async (config, isSkipSave = false) => { // set isSk
5757
config = await loadStatFile(config)
5858

5959
// load checksum file & calc hash
60-
const checksumHash = calcHash(await fsAsync.readFile(config.pathChecksumFile), 'sha256')
60+
const checksumHash = calcHash(await readBuffer(config.pathChecksumFile), 'sha256')
6161

6262
// detect hash change
6363
const isHashChanged = Boolean(config.stat.checksumHash && (config.stat.checksumHash !== checksumHash))

source/node/cache/checksum.test.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { promises as fsAsync } from 'fs'
21
import { resolve } from 'path'
32
import { strictEqual } from '@dr-js/core/module/common/verify.js'
43
import { getSampleRange } from '@dr-js/core/module/common/math/sample.js'
4+
import { writeText } from '@dr-js/core/module/node/fs/File.js'
55
import { createDirectory, resetDirectory } from '@dr-js/core/module/node/fs/Directory.js'
66
import { modifyDelete } from '@dr-js/core/module/node/fs/Modify.js'
77
import { describeChecksumOfPathList } from '@dr-js/core/module/node/fs/Checksum.js'
@@ -31,13 +31,13 @@ const TEST_CONFIG = {
3131
before(async () => {
3232
await resetDirectory(TEST_ROOT)
3333

34-
await fsAsync.writeFile(fromRoot('sample-cache-file-0'), 'sample-cache-file-0')
35-
await fsAsync.writeFile(fromRoot('sample-cache-file-1'), 'sample-cache-file-1')
34+
await writeText(fromRoot('sample-cache-file-0'), 'sample-cache-file-0')
35+
await writeText(fromRoot('sample-cache-file-1'), 'sample-cache-file-1')
3636

3737
await createDirectory(fromRoot('sample-cache-dir-0'))
38-
for (const index of getSampleRange(0, 5)) await fsAsync.writeFile(fromRoot('sample-cache-dir-0', `dir-0-${index}`), `dir-0-${index}`)
38+
for (const index of getSampleRange(0, 5)) await writeText(fromRoot('sample-cache-dir-0', `dir-0-${index}`), `dir-0-${index}`)
3939
await createDirectory(fromRoot('sample-cache-dir-1'))
40-
for (const index of getSampleRange(0, 5)) await fsAsync.writeFile(fromRoot('sample-cache-dir-1', `dir-1-${index}`), `dir-1-${index}`)
40+
for (const index of getSampleRange(0, 5)) await writeText(fromRoot('sample-cache-dir-1', `dir-1-${index}`), `dir-1-${index}`)
4141
})
4242
after(async () => {
4343
await modifyDelete(TEST_ROOT)
@@ -53,7 +53,7 @@ describe('Node.Cache.Checksum', () => {
5353
strictEqual((await checksumDetectChange(TEST_CONFIG)).isHashChanged, false)
5454
strictEqual((await checksumDetectChange(TEST_CONFIG)).isHashChanged, false)
5555

56-
await fsAsync.writeFile(fromRoot('sample-cache-file-1'), 'sample-cache-file-1 UPDATE')
56+
await writeText(fromRoot('sample-cache-file-1'), 'sample-cache-file-1 UPDATE')
5757
__DEV__ && info(await describeChecksumOfPathList({ pathList: TEST_CONFIG.pathChecksumList }))
5858

5959
strictEqual((await checksumUpdate(TEST_CONFIG)).isHashChanged, true)

source/node/cache/function.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { dirname } from 'path'
2-
import { promises as fsAsync } from 'fs'
2+
import { withFallbackResultAsync } from '@dr-js/core/module/common/error.js'
3+
import { readJSON, writeJSONPretty } from '@dr-js/core/module/node/fs/File.js'
34
import { createDirectory } from '@dr-js/core/module/node/fs/Directory.js'
45

56
const packTime = (timeDate) => timeDate === undefined ? '' : timeDate.toISOString()
@@ -14,7 +15,7 @@ const loadStat = async (
1415
config = { ...config }
1516

1617
// load rawStat
17-
config.rawStat = JSON.parse(String(await fsAsync.readFile(config.pathStatFile).catch(() => null))) || {}
18+
config.rawStat = await withFallbackResultAsync({}, readJSON, config.pathStatFile)
1819
if (!config.rawStat[ statKey ]) config.rawStat[ statKey ] = {}
1920

2021
// parse rawStat
@@ -33,7 +34,7 @@ const saveStat = async (
3334

3435
// write out
3536
await createDirectory(dirname(config.pathStatFile))
36-
await fsAsync.writeFile(config.pathStatFile, JSON.stringify(config.rawStat, null, 2))
37+
await writeJSONPretty(config.pathStatFile, config.rawStat)
3738
}
3839

3940
export {

source/node/cache/staleCheck.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { dirname } from 'path'
2-
import { promises as fsAsync } from 'fs'
32
import { binary } from '@dr-js/core/module/common/format.js'
43
import { createAsyncLane, extendAutoSelectLane } from '@dr-js/core/module/common/module/AsyncLane.js'
54

65
import { PATH_TYPE, getPathStat, getPathTypeFromStat } from '@dr-js/core/module/node/fs/Path.js'
6+
import { writeJSONPretty } from '@dr-js/core/module/node/fs/File.js'
77
import { getDirInfoTree, walkDirInfoTreeAsync, createDirectory } from '@dr-js/core/module/node/fs/Directory.js'
88

99
import { packTime, parseTime, loadStat, saveStat } from './function.js'
@@ -115,7 +115,7 @@ const staleCheckCalcReport = async (
115115
// save report if needed
116116
if (config.pathStaleCheckFile) {
117117
await createDirectory(dirname(config.pathStaleCheckFile))
118-
await fsAsync.writeFile(config.pathStaleCheckFile, JSON.stringify(report, null, 2))
118+
await writeJSONPretty(config.pathStaleCheckFile, report)
119119
}
120120

121121
return { report }

source/node/cache/staleCheck.test.js

+13-13
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { resolve } from 'path'
2-
import { promises as fsAsync } from 'fs'
32
import { setTimeoutAsync } from '@dr-js/core/module/common/time.js'
43
import { getSampleRange } from '@dr-js/core/module/common/math/sample.js'
4+
import { readText, writeText } from '@dr-js/core/module/node/fs/File.js'
55
import { createDirectory, resetDirectory } from '@dr-js/core/module/node/fs/Directory.js'
66
import { modifyDelete } from '@dr-js/core/module/node/fs/Modify.js'
77

@@ -38,19 +38,19 @@ const TEST_CONFIG = {
3838
before(async () => {
3939
await resetDirectory(TEST_ROOT)
4040

41-
await fsAsync.writeFile(fromRoot('sample-cache-file-0'), 'sample-cache-file-0')
42-
await fsAsync.writeFile(fromRoot('sample-cache-file-1'), 'sample-cache-file-1')
43-
await fsAsync.writeFile(fromRoot('sample-cache-file-2'), 'sample-cache-file-2')
41+
await writeText(fromRoot('sample-cache-file-0'), 'sample-cache-file-0')
42+
await writeText(fromRoot('sample-cache-file-1'), 'sample-cache-file-1')
43+
await writeText(fromRoot('sample-cache-file-2'), 'sample-cache-file-2')
4444

4545
await createDirectory(fromRoot('sample-cache-dir-0'))
46-
for (const index of getSampleRange(0, 5)) await fsAsync.writeFile(fromRoot('sample-cache-dir-0', `dir-0-${index}`), `dir-0-${index}`)
46+
for (const index of getSampleRange(0, 5)) await writeText(fromRoot('sample-cache-dir-0', `dir-0-${index}`), `dir-0-${index}`)
4747

4848
await setTimeoutAsync(50)
4949

50-
await fsAsync.writeFile(fromRoot('sample-cache-file-3'), 'sample-cache-file-3')
50+
await writeText(fromRoot('sample-cache-file-3'), 'sample-cache-file-3')
5151

5252
await createDirectory(fromRoot('sample-cache-dir-1'))
53-
for (const index of getSampleRange(0, 5)) await fsAsync.writeFile(fromRoot('sample-cache-dir-1', `dir-1-${index}`), `dir-1-${index}`)
53+
for (const index of getSampleRange(0, 5)) await writeText(fromRoot('sample-cache-dir-1', `dir-1-${index}`), `dir-1-${index}`)
5454
})
5555
after(async () => {
5656
await modifyDelete(TEST_ROOT)
@@ -61,22 +61,22 @@ describe('Node.Cache.StaleCheck', () => {
6161
await staleCheckSetup(TEST_CONFIG)
6262
await setTimeoutAsync(10)
6363

64-
await fsAsync.writeFile(fromRoot('sample-cache-file-4'), 'sample-cache-file-4')
64+
await writeText(fromRoot('sample-cache-file-4'), 'sample-cache-file-4')
6565

6666
await createDirectory(fromRoot('sample-cache-dir-2'))
67-
for (const index of getSampleRange(0, 5)) await fsAsync.writeFile(fromRoot('sample-cache-dir-2', `dir-2-${index}`), `dir-2-${index}`)
67+
for (const index of getSampleRange(0, 5)) await writeText(fromRoot('sample-cache-dir-2', `dir-2-${index}`), `dir-2-${index}`)
6868

6969
await createDirectory(fromRoot('sample-cache-dir-3'))
70-
for (const index of getSampleRange(0, 5)) await fsAsync.writeFile(fromRoot('sample-cache-dir-3', `dir-3-${index}`), `dir-3-${index}`)
70+
for (const index of getSampleRange(0, 5)) await writeText(fromRoot('sample-cache-dir-3', `dir-3-${index}`), `dir-3-${index}`)
7171

7272
await staleCheckMark(TEST_CONFIG)
7373
await setTimeoutAsync(10)
7474

7575
await createDirectory(fromRoot('sample-cache-dir-3'))
76-
for (const index of getSampleRange(3, 5)) await fsAsync.readFile(fromRoot('sample-cache-dir-2', `dir-2-${index}`))
77-
for (const index of getSampleRange(0, 5)) await fsAsync.writeFile(fromRoot('sample-cache-dir-3', `dir-3-${index}`), `dir-3-${index}`)
76+
for (const index of getSampleRange(3, 5)) await readText(fromRoot('sample-cache-dir-2', `dir-2-${index}`))
77+
for (const index of getSampleRange(0, 5)) await writeText(fromRoot('sample-cache-dir-3', `dir-3-${index}`), `dir-3-${index}`)
7878
await createDirectory(fromRoot('sample-cache-dir-4'))
79-
for (const index of getSampleRange(0, 5)) await fsAsync.writeFile(fromRoot('sample-cache-dir-4', `dir-4-${index}`), `dir-4-${index}`)
79+
for (const index of getSampleRange(0, 5)) await writeText(fromRoot('sample-cache-dir-4', `dir-4-${index}`), `dir-4-${index}`)
8080

8181
const { report } = await staleCheckCalcReport(TEST_CONFIG)
8282

source/node/cache/staleCheckDetect.test.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const { resolve } = require('path')
2-
const { promises: fsAsync } = require('fs')
32
const { setTimeoutAsync } = require('@dr-js/core/library/common/time.js')
43
const { getPathStat } = require('@dr-js/core/library/node/fs/Path.js')
4+
const { readText, writeText } = require('@dr-js/core/library/node/fs/File.js')
55
const { createDirectory } = require('@dr-js/core/library/node/fs/Directory.js')
66
const { modifyDeleteForce } = require('@dr-js/core/library/node/fs/Modify.js')
77

@@ -17,23 +17,23 @@ const main = async () => {
1717

1818
const PATH_FILE = fromRoot('test')
1919

20-
await fsAsync.writeFile(PATH_FILE, 'init')
20+
await writeText(PATH_FILE, 'init')
2121
await setTimeoutAsync(10)
2222
console.log('init ', getStatTime(await getPathStat(PATH_FILE)))
2323

24-
await fsAsync.readFile(PATH_FILE)
24+
await readText(PATH_FILE)
2525
await setTimeoutAsync(10)
2626
console.log('read ', getStatTime(await getPathStat(PATH_FILE)))
2727

28-
await fsAsync.writeFile(PATH_FILE, 'write')
28+
await writeText(PATH_FILE, 'write')
2929
await setTimeoutAsync(10)
3030
console.log('write ', getStatTime(await getPathStat(PATH_FILE)))
3131

32-
await fsAsync.readFile(PATH_FILE)
32+
await readText(PATH_FILE)
3333
await setTimeoutAsync(10)
3434
console.log('read ', getStatTime(await getPathStat(PATH_FILE)))
3535

36-
await fsAsync.writeFile(PATH_FILE, 'write')
36+
await writeText(PATH_FILE, 'write')
3737
await setTimeoutAsync(10)
3838
console.log('write ', getStatTime(await getPathStat(PATH_FILE)))
3939

source/node/export/parse.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { sep } from 'path'
2-
import { readFileSync } from 'fs'
32
import { parse as parseAST } from '@babel/parser'
43
import { compareString } from '@dr-js/core/module/common/compare.js'
54
import { objectSortKey } from '@dr-js/core/module/common/mutable/Object.js'
65
import { getPathStat, getPathTypeFromStat } from '@dr-js/core/module/node/fs/Path.js'
6+
import { readTextSync } from '@dr-js/core/module/node/fs/File.js'
77

88
const getExportListFromParsedAST = (fileString, sourceFilename, parserPluginList) => {
99
const resultAST = parseAST(fileString, {
@@ -61,7 +61,7 @@ const createExportParser = ({
6161
kitLogger.devLog(`[directory] ${path}`)
6262
getRoute(routeList).directoryList.push(name)
6363
} else if (fileStat.isFile() && name.endsWith('.js')) {
64-
const fileString = String(readFileSync(path))
64+
const fileString = readTextSync(path)
6565
const exportList = getExportListFromParsedAST(fileString, path, parserPluginList)
6666

6767
kitLogger.devLog(`[file] ${path}`)

0 commit comments

Comments
 (0)