Skip to content

Commit

Permalink
check whether a file path should be overwritten
Browse files Browse the repository at this point in the history
  • Loading branch information
lmgyuan committed May 24, 2024
1 parent 55f9ae7 commit 900faa9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
3 changes: 0 additions & 3 deletions lib/generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -963,9 +963,6 @@ class Generator {
* @return {Promise<boolean>}
*/
async shouldOverwriteFile(filePath) {
const fullPath = path.resolve(this.targetDir, filePath);
// Additional logging for debugging purposes

if (!Array.isArray(this.noOverwriteGlobs)) return true;
const fileExists = await exists(path.resolve(this.targetDir, filePath));
if (!fileExists) return true;
Expand Down
4 changes: 3 additions & 1 deletion lib/renderer/react.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ const saveContentToFile = async (renderedContent, outputPath, noOverwriteGlobs =
// get the final file name of the file
const finalFileName = path.basename(filePath);
// check whether the filename should be ignored based on user's inputs
const shouldOverwrite = !noOverwriteGlobs.some(globExp => minimatch(finalFileName, globExp));
// const shouldOverwrite = !noOverwriteGlobs.some(globExp => minimatch(finalFileName, globExp));
// reuse methods from the generator.js to check if the file should be overwritten
const shouldOverwrite = await reactExport.shouldOverwriteFile(filePath, noOverwriteGlobs);

// Write the file only if it should not be skipped
if (shouldOverwrite) {
Expand Down

0 comments on commit 900faa9

Please sign in to comment.