Skip to content

Commit a24b479

Browse files
committed
fix(merge): file merge handler unusable
fix #19
1 parent b6faeef commit a24b479

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

src/handlers/merge.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,21 +33,21 @@ const mergeJson = file => {
3333

3434
return {
3535
...file,
36-
content: JSON.stringify(merge({ targetFileContent, content }), null, ' ')
36+
content: JSON.stringify(merge(targetFileContent, content), null, ' ')
3737
}
3838
}
3939

4040
module.exports = createHandler(file => {
4141
file = readTargetFile(file)
4242

4343
if (file.targetFile.exist) {
44-
if (extname(file.targetPath) === 'json') return mergeJson(file)
44+
if (extname(file.targetPath) === '.json') return mergeJson(file)
4545
else {
4646
log.error('merge', [
47-
`Merge files of this type(${extname(file.targetFile)}) are not supported by mili`,
47+
`Merge files of this type(${extname(file.targetPath)}) are not supported by mili`,
4848
'please confirm if the loaded template supports the current mili version,',
4949
'and feedback this question to the template developer.',
50-
'The current file will be overwritten directly by the template file.'
50+
'The current file will be overwritten directly by the template file.',
5151
`path: ${file.targetPath}`
5252
].join('\n'))
5353
}

src/handlers/readTargetFile.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
1-
const { readFileSync, accessSync } = require('fs')
1+
const fs = require('fs')
22

33

44
module.exports = file => {
55
if (file.targetFile) return file
66

77
try {
8-
accessSync(targetFile, F_OK)
8+
fs.accessSync(file.targetPath, fs.constants.F_OK)
99
} catch(e) {
10+
console.log('exist', e)
1011
return { ...file, targetFile: { exist: false } }
1112
}
1213

13-
const content = readFileSync(file.targetPath, file.encoding)
14+
const content = fs.readFileSync(file.targetPath, file.encoding)
1415
return {
1516
...file,
1617
targetFile: {

0 commit comments

Comments
 (0)