Skip to content

Commit

Permalink
fixes sveltejs#144 - do not delete scripts folder if it is not empty (s…
Browse files Browse the repository at this point in the history
…veltejs#147)

* fixes sveltejs#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 <orta.therox+github@gmail.com>
  • Loading branch information
opensas and orta authored Jul 27, 2020
1 parent 16e4763 commit 0ed46da
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions scripts/setupTypeScript.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,18 @@ fs.writeFileSync(tsconfigPath, tsconfig)
if (!argv[2]) {
// Remove the script
fs.unlinkSync(path.join(__filename))
// Remove the scripts folder
fs.rmdirSync(path.join(__dirname))

// Check for Mac's DS_store file, and if it's the only one left remove it
const remainingFiles = fs.readdirSync(path.join(__dirname))
if (remainingFiles.length === 1 && remainingFiles[0] === '.DS_store') {
fs.unlinkSync(path.join(__dirname, '.DS_store'))
}

// Check if the scripts folder is empty
if (fs.readdirSync(path.join(__dirname)).length === 0) {
// Remove the scripts folder
fs.rmdirSync(path.join(__dirname))
}
}

// Adds the extension recommendation
Expand Down

0 comments on commit 0ed46da

Please sign in to comment.