Check file annotation before deleting the index.ts
benjamin658 opened this issue · 0 comments
benjamin658 commented
Lines 17 to 23 in 103a1cd
Currently, the -d
option will delete the index.ts before generating a new one, however, it could delete the user's files that were not created by the barrelsby.
I recommend adding another filter to check if the file that is going to be deleted has the @file Automatically generated by barrelsby.
annotation.
//..skip
directory.files
.filter((file) => {
const isGenerated = fs.readFileSync(file.path).includes('@file Automatically generated by barrelsby.');
return file.name === barrelName && isGenerated;
})