@@ -58,7 +58,6 @@ opts = {}
58
58
sources = []
59
59
sourceCode = []
60
60
notSources = {}
61
- watchers = {}
62
61
optionParser = null
63
62
64
63
# Run `coffee` by parsing passed options and determining what action to take.
@@ -89,31 +88,35 @@ exports.run = ->
89
88
# is passed, recursively compile all '.coffee', '.litcoffee', and '.coffee.md'
90
89
# extension source files in it and all subdirectories.
91
90
compilePath = (source , topLevel , base ) ->
92
- fs .stat source, (err , stats ) ->
93
- throw err if err and err .code isnt ' ENOENT'
94
- if err ? .code is ' ENOENT'
91
+ try
92
+ stats = fs .statSync source
93
+ catch err
94
+ if err .code is ' ENOENT'
95
95
console .error " File not found: #{ source} "
96
96
process .exit 1
97
- if stats .isDirectory () and path .dirname (source) isnt ' node_modules'
98
- watchDir source, base if opts .watch
99
- fs .readdir source, (err , files ) ->
100
- throw err if err and err .code isnt ' ENOENT'
101
- return if err ? .code is ' ENOENT'
102
- index = sources .indexOf source
103
- files = files .filter (file) -> not hidden file
104
- sources[index.. index] = (path .join source, file for file in files)
105
- sourceCode[index.. index] = files .map -> null
106
- files .forEach (file) ->
107
- compilePath (path .join source, file), no , base
108
- else if topLevel or helpers .isCoffee source
109
- watch source, base if opts .watch
110
- fs .readFile source, (err , code ) ->
111
- throw err if err and err .code isnt ' ENOENT'
112
- return if err ? .code is ' ENOENT'
113
- compileScript (source, code .toString (), base)
114
- else
115
- notSources[source] = yes
116
- removeSource source, base
97
+ throw err
98
+ if stats .isDirectory () and path .dirname (source) isnt ' node_modules'
99
+ watchDir source, base if opts .watch
100
+ try
101
+ files = fs .readdirSync source
102
+ catch err
103
+ if err .code is ' ENOENT' then return else throw err
104
+ index = sources .indexOf source
105
+ files = files .filter (file) -> not hidden file
106
+ sources[index.. index] = (path .join source, file for file in files)
107
+ sourceCode[index.. index] = files .map -> null
108
+ files .forEach (file) ->
109
+ compilePath (path .join source, file), no , base
110
+ else if topLevel or helpers .isCoffee source
111
+ watch source, base if opts .watch
112
+ try
113
+ code = fs .readFileSync source
114
+ catch err
115
+ if err .code is ' ENOENT' then return else throw err
116
+ compileScript (source, code .toString (), base)
117
+ else
118
+ notSources[source] = yes
119
+ removeSource source, base
117
120
118
121
119
122
# Compile a single source script, containing the given code, according to the
0 commit comments