diff --git a/package.json b/package.json index 53ee0f481..3d6d20f47 100644 --- a/package.json +++ b/package.json @@ -23,6 +23,7 @@ "keytar": "0.4.0", "ls-archive": "0.9.0", "temp": "0.5.0", + "rimraf": "2.1.4", "plist": "git://github.com/nathansobo/node-plist.git", "space-pen": "1.0.0", "less": "git://github.com/nathansobo/less.js.git", diff --git a/src/stdlib/fs-utils.coffee b/src/stdlib/fs-utils.coffee index 45fcf3014..54322a694 100644 --- a/src/stdlib/fs-utils.coffee +++ b/src/stdlib/fs-utils.coffee @@ -3,6 +3,7 @@ fs = require 'fs' mkdirp = require 'mkdirp' Module = require 'module' async = require 'async' +rimraf = require 'rimraf' module.exports = # Make the given path absolute by resolving it against the @@ -134,20 +135,8 @@ module.exports = # Remove a file at the given path. Throws an error if path is not a # file or a symbolic link to a file. - remove: (path) -> - if @isFile(path) - fs.unlinkSync(path) - else if @isDirectory(path) - removeDirectory = (path) => - for entry in fs.readdirSync(path) - entryPath = @join(path, entry) - stats = fs.statSync(entryPath) - if stats.isDirectory() - removeDirectory(entryPath) - else if stats.isFile() - fs.unlinkSync(entryPath) - fs.rmdirSync(path) - removeDirectory(path) + remove: (pathToRemove) -> + rimraf.sync(pathToRemove) # Open, read, and close a file, returning the file's contents. read: (path) ->