42 lines
1.4 KiB
JavaScript
42 lines
1.4 KiB
JavaScript
const fs = require('fs');
|
||
const path = 'D:\\project\\zhizhu\\components\\PhotoUploadForm.vue';
|
||
const content = fs.readFileSync(path, 'utf8');
|
||
const lines = content.split('\n');
|
||
|
||
console.log('=== Current file ending ===');
|
||
console.log('Lines 1993-2000:');
|
||
for (let i = 1992; i < 2000; i++) {
|
||
console.log(`Line ${i + 1}: "${lines[i]}"`);
|
||
}
|
||
|
||
// 检查 Line 1996 的内容
|
||
console.log('\nLine 1996 content analysis:');
|
||
console.log(` Raw: "${lines[1995]}"`);
|
||
console.log(` Length: ${lines[1995].length}`);
|
||
console.log(` Trimmed: "${lines[1995].trim()}"`);
|
||
|
||
// 如果 Line 1996 是 " };"(1个tab + 分号),需要改成 " },"(1个tab + 逗号)
|
||
if (lines[1995].trim() === '};') {
|
||
// 检查前面是否有 tab
|
||
const hasTab = lines[1995].startsWith('\t');
|
||
if (hasTab) {
|
||
console.log('\nFixing Line 1996: changing " };" to " },"');
|
||
lines[1995] = '\t},';
|
||
|
||
// 写回文件
|
||
const newContent = lines.join('\n');
|
||
fs.writeFileSync(path, newContent, 'utf8');
|
||
console.log('File updated successfully!');
|
||
|
||
// 验证
|
||
console.log('\n=== After fix ===');
|
||
for (let i = 1992; i < 2000; i++) {
|
||
console.log(`Line ${i + 1}: "${lines[i]}"`);
|
||
}
|
||
} else {
|
||
console.log('Line 1996 does not start with tab, checking further...');
|
||
console.log(` First char: "${lines[1995][0]}" (code: ${lines[1995].charCodeAt(0)})`);
|
||
}
|
||
} else {
|
||
console.log(`Line 1996 is not "};", it's "${lines[1995]}"`);
|
||
} |