-
Notifications
You must be signed in to change notification settings - Fork 79
delete leftover directories #169
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -221,18 +221,31 @@ class Applesign { | |
| await tools.asyncRimraf(placeholderdir); | ||
| } | ||
|
|
||
| // XXX some directory leftovers | ||
| async removeXCTests() { | ||
| fchk(arguments, []); | ||
| let dirsToCheck: Set<string> = new Set<string>(); | ||
| const dir = this.config.appdir; | ||
| walk.walkSync(dir, (basedir: string, filename: string, stat: any) => { | ||
| const target = path.join(basedir, filename); | ||
| // if (target.toLowerCase().indexOf('/xct') !== -1) | ||
| if (target.toLowerCase().indexOf("xctest") !== -1) { | ||
| this.emit("message", "Deleting " + target); | ||
| fs.unlinkSync(target); | ||
| dirsToCheck.add(basedir); | ||
| } | ||
| }); | ||
| let removedDirs: Set<string> = new Set<string>(); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It’s unclear to me the need to define a set of paths, an array should be fine and simpler because you cant have two different paths with the same path
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. simplify the loop iteration, the filter to remove the element from the set is adding an extra complication that is not necessary. |
||
| do { | ||
| removedDirs = new Set<string>(); | ||
| for (const d of dirsToCheck) { | ||
| if (fs.readdirSync(d).length === 0) { | ||
| this.emit('message', 'Deleting ' + d); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use “ instead of ‘ (see ci complains) |
||
| fs.rmdirSync(d); | ||
| removedDirs.add(d); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. From what i understand this code is deleting empty directories. But if an empty directory is contained within a directory that only had this one it wont be removed, so the removal must happen recursively. |
||
| } | ||
| } | ||
| dirsToCheck = new Set([...dirsToCheck].filter((d) => !removedDirs.has(d))); | ||
| } while (removedDirs.size > 0); | ||
| } | ||
|
|
||
| async removeSigningFiles() { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This check is probably safer