Skip to content

Commit

Permalink
apply patch from original coffee-script: ignore hidden files/dir
Browse files Browse the repository at this point in the history
jashkenas/coffee-script: fixes #1537: ignore hidden files/directories in watched directories
  • Loading branch information
yyfearth committed Feb 23, 2012
1 parent 2e0dd76 commit 5d36e63
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 19 deletions.
2 changes: 2 additions & 0 deletions Cakefile
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ task 'install', 'install CoffeeScript into /usr/local (or --prefix)', (options)
console.log "Installing CoffeeScript to #{lib}"
console.log "Linking to #{node}"
console.log "Linking 'coffee' to #{bin}/xcoffee"
console.log "Linking 'cake' to #{bin}/xcake"
console.log "Linking 'cson' to #{bin}/xcson"
exec([
"mkdir -p #{lib} #{bin}"
"cp -rf bin lib LICENSE README package.json src #{lib}"
Expand Down
35 changes: 22 additions & 13 deletions lib/coffee-script/command.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/coffee-script/nodes.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 7 additions & 5 deletions src/command.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ helpers.extend CoffeeScript, new EventEmitter
printLine = (line) -> process.stdout.write line + '\n'
printWarn = (line) -> process.stderr.write line + '\n'

hidden = (file) -> /^\.|~$/.test file

# The help banner that is printed when `coffee` is called without arguments.
BANNER = '''
Usage: iced [options] path/to/script.coffee
Expand Down Expand Up @@ -105,11 +107,11 @@ compilePath = (source, topLevel, base) ->
fs.readdir source, (err, files) ->
throw err if err and err.code isnt 'ENOENT'
return if err?.code is 'ENOENT'
files = files.map (file) -> path.join source, file
index = sources.indexOf source
sources[index..index] = files
sources[index..index] = (path.join source, file for file in files)
sourceCode[index..index] = files.map -> null
compilePath file, no, base for file in files
for file in files when not hidden file
compilePath (path.join source, file), no, base
else if topLevel or path.extname(source) is '.coffee'
watch source, base if opts.watch
fs.readFile source, (err, code) ->
Expand Down Expand Up @@ -238,8 +240,8 @@ watchDir = (source, base) ->
throw err unless err.code is 'ENOENT'
watcher.close()
return unwatchDir source, base
files = files.map (file) -> path.join source, file
for file in files when not notSources[file]
for file in files when not hidden(file) and not notSources[file]
file = path.join source, file
continue if sources.some (s) -> s.indexOf(file) >= 0
sources.push file
sourceCode.push null
Expand Down

0 comments on commit 5d36e63

Please sign in to comment.