Skip to content
This repository was archived by the owner on Feb 15, 2023. It is now read-only.

Commit 0ed46da

Browse files
opensasorta
andauthored
fixes #144 - do not delete scripts folder if it is not empty (#147)
* fixes #144 - do not delete scripts folder if it is not empty * fixes 144 - do not remove scripts forlder if not empty, checking for DS_store file * fixes 144 - do not remove scripts forlder if not empty, checking DS_store is the only remaining file * Update scripts/setupTypeScript.js * Apply suggestions from code review Co-authored-by: Orta Therox <[email protected]>
1 parent 16e4763 commit 0ed46da

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

scripts/setupTypeScript.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,18 @@ fs.writeFileSync(tsconfigPath, tsconfig)
9797
if (!argv[2]) {
9898
// Remove the script
9999
fs.unlinkSync(path.join(__filename))
100-
// Remove the scripts folder
101-
fs.rmdirSync(path.join(__dirname))
100+
101+
// Check for Mac's DS_store file, and if it's the only one left remove it
102+
const remainingFiles = fs.readdirSync(path.join(__dirname))
103+
if (remainingFiles.length === 1 && remainingFiles[0] === '.DS_store') {
104+
fs.unlinkSync(path.join(__dirname, '.DS_store'))
105+
}
106+
107+
// Check if the scripts folder is empty
108+
if (fs.readdirSync(path.join(__dirname)).length === 0) {
109+
// Remove the scripts folder
110+
fs.rmdirSync(path.join(__dirname))
111+
}
102112
}
103113

104114
// Adds the extension recommendation

0 commit comments

Comments
 (0)