Skip to content

Commit f60cf7a

Browse files
committed
removed duplicate callback when async===true (solves #89)
1 parent 5070b1d commit f60cf7a

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

coffee/docUtils.coffee

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,7 @@ DocUtils.loadDoc= (path,options={}) ->
7575
loadFile(result)
7676
,async
7777
else
78-
httpRegex= new RegExp "(https?)","i"
79-
# httpsRegex= new RegExp "(https)://"
80-
if httpRegex.test(path)
78+
if path.indexOf("http")==0
8179
urloptions=(url.parse(path))
8280
options =
8381
hostname:urloptions.hostname
@@ -102,22 +100,19 @@ DocUtils.loadDoc= (path,options={}) ->
102100
when 'http:'
103101
req = http.request(options, reqCallback).on('error',errorCallback)
104102
req.end();
105-
106103
else
107104
if async==true
108105
fs.readFile totalPath,"binary", (err, data) ->
109106
if err
110-
if callback? then return callback(true)
107+
if callback? then return callback(err)
111108
else
112-
loadFile(data)
113-
if callback? then return callback(data)
109+
return loadFile(data)
114110
else
115111
try
116112
data=fs.readFileSync(totalPath,"binary")
117-
a=loadFile(data)
118-
if callback? then return callback(data) else return a
113+
return loadFile(data)
119114
catch e
120-
if callback? then return callback()
115+
if callback? then return callback(e)
121116

122117
DocUtils.loadHttp=(result,callback,async=false)->
123118
if DocUtils.env=='node'

0 commit comments

Comments
 (0)