RosettaCodeData/Task/Empty-directory/CoffeeScript/empty-directory.coffee

8 lines
202 B
CoffeeScript
Raw Permalink Normal View History

2013-04-10 16:57:12 -07:00
fs = require 'fs'
is_empty_dir = (dir) ->
throw Error "#{dir} is not a dir" unless fs.statSync(dir).isDirectory()
# readdirSync does not return . or ..
fns = fs.readdirSync dir
fns.length == 0