chore: support idl files of cn2en script (#336)
This commit is contained in:
parent
bb74272385
commit
ab82507fd2
|
|
@ -21,7 +21,7 @@ const DEFAULT_CONFIG: AppConfig = {
|
||||||
'yaml', 'yml', 'toml', 'ini', 'conf', 'config',
|
'yaml', 'yml', 'toml', 'ini', 'conf', 'config',
|
||||||
'sh', 'bash', 'zsh', 'fish', 'py', 'css', 'scss', 'sass', 'less',
|
'sh', 'bash', 'zsh', 'fish', 'py', 'css', 'scss', 'sass', 'less',
|
||||||
'html', 'htm', 'xml', 'php', 'rb', 'rs', 'java', 'c', 'h',
|
'html', 'htm', 'xml', 'php', 'rb', 'rs', 'java', 'c', 'h',
|
||||||
'cpp', 'cxx', 'cc', 'hpp', 'cs'
|
'cpp', 'cxx', 'cc', 'hpp', 'cs', 'thrift'
|
||||||
],
|
],
|
||||||
outputFormat: 'console'
|
outputFormat: 'console'
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -57,9 +57,7 @@ export const getSourceFiles = async (config: FileScanConfig): Promise<Result<str
|
||||||
files = files.filter(isTextFile);
|
files = files.filter(isTextFile);
|
||||||
|
|
||||||
// 根据扩展名过滤
|
// 根据扩展名过滤
|
||||||
if (extensions.length > 0) {
|
|
||||||
files = filterFilesByExtensions(files, extensions);
|
files = filterFilesByExtensions(files, extensions);
|
||||||
}
|
|
||||||
|
|
||||||
return files;
|
return files;
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@ export type SourceFileLanguage =
|
||||||
| 'c'
|
| 'c'
|
||||||
| 'cpp'
|
| 'cpp'
|
||||||
| 'csharp'
|
| 'csharp'
|
||||||
|
| 'thrift'
|
||||||
| 'other';
|
| 'other';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,8 @@ export const detectLanguage = (filePath: string): SourceFileLanguage => {
|
||||||
'cxx': 'cpp',
|
'cxx': 'cpp',
|
||||||
'cc': 'cpp',
|
'cc': 'cpp',
|
||||||
'hpp': 'cpp',
|
'hpp': 'cpp',
|
||||||
'cs': 'csharp'
|
'cs': 'csharp',
|
||||||
|
'thrift': 'thrift'
|
||||||
};
|
};
|
||||||
|
|
||||||
return languageMap[ext || ''] || 'other';
|
return languageMap[ext || ''] || 'other';
|
||||||
|
|
@ -63,7 +64,7 @@ export const filterFilesByExtensions = (
|
||||||
'.yaml', '.yml', '.toml', '.ini', '.conf', '.config',
|
'.yaml', '.yml', '.toml', '.ini', '.conf', '.config',
|
||||||
'.sh', '.bash', '.zsh', '.fish', '.py', '.css', '.scss', '.sass', '.less',
|
'.sh', '.bash', '.zsh', '.fish', '.py', '.css', '.scss', '.sass', '.less',
|
||||||
'.html', '.htm', '.xml', '.php', '.rb', '.rs', '.java', '.c', '.h',
|
'.html', '.htm', '.xml', '.php', '.rb', '.rs', '.java', '.c', '.h',
|
||||||
'.cpp', '.cxx', '.cc', '.hpp', '.cs'
|
'.cpp', '.cxx', '.cc', '.hpp', '.cs', '.thrift'
|
||||||
];
|
];
|
||||||
return files.filter(file =>
|
return files.filter(file =>
|
||||||
defaultExtensions.some(ext => file.toLowerCase().endsWith(ext))
|
defaultExtensions.some(ext => file.toLowerCase().endsWith(ext))
|
||||||
|
|
@ -191,6 +192,11 @@ export const getCommentPatterns = (language: SourceFileLanguage): CommentPattern
|
||||||
multiStart: /\/\*/g,
|
multiStart: /\/\*/g,
|
||||||
multiEnd: /\*\//g
|
multiEnd: /\*\//g
|
||||||
},
|
},
|
||||||
|
thrift: {
|
||||||
|
single: /\/\/(.*)$/gm,
|
||||||
|
multiStart: /\/\*/g,
|
||||||
|
multiEnd: /\*\//g
|
||||||
|
},
|
||||||
other: {
|
other: {
|
||||||
single: /\/\/(.*)$/gm,
|
single: /\/\/(.*)$/gm,
|
||||||
multiStart: /\/\*/g,
|
multiStart: /\/\*/g,
|
||||||
|
|
@ -218,7 +224,7 @@ export const isTextFile = (filePath: string): boolean => {
|
||||||
'.css', '.scss', '.sass', '.less', '.html', '.htm', '.xml',
|
'.css', '.scss', '.sass', '.less', '.html', '.htm', '.xml',
|
||||||
'.yaml', '.yml', '.toml', '.ini', '.conf', '.config',
|
'.yaml', '.yml', '.toml', '.ini', '.conf', '.config',
|
||||||
'.sh', '.bash', '.zsh', '.fish', '.py', '.java', '.c', '.cpp', '.h', '.hpp', '.cs',
|
'.sh', '.bash', '.zsh', '.fish', '.py', '.java', '.c', '.cpp', '.h', '.hpp', '.cs',
|
||||||
'.php', '.rb', '.rs', '.kt', '.swift', '.dart', '.scala'
|
'.php', '.rb', '.rs', '.kt', '.swift', '.dart', '.scala', '.thrift'
|
||||||
];
|
];
|
||||||
|
|
||||||
return textExtensions.some(ext =>
|
return textExtensions.some(ext =>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue