Use rimraf for removing files/folders

This commit is contained in:
Kevin Sawicki 2013-06-12 15:09:54 -07:00
parent b96597b089
commit 437137783c
2 changed files with 4 additions and 14 deletions

View File

@ -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",

View File

@ -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) ->