Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

callback on nextTick to avoid zalgo #57

Merged
merged 2 commits into from
Feb 18, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 8 additions & 10 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ module.exports = {
join(process.env.HOME ||
process.env.USERPROFILE, '.ipfs')
}
done(null, new Node(path))
process.nextTick(() => {
done(null, new Node(path))
})
},
disposableApi (opts, done) {
if (typeof opts === 'function') {
Expand All @@ -29,10 +31,7 @@ module.exports = {
}
this.disposable(opts, (err, node) => {
if (err) return done(err)
node.startDaemon((err, api) => {
if (err) return done(err)
done(null, api)
})
node.startDaemon(done)
})
},
disposable (opts, done) {
Expand All @@ -46,13 +45,12 @@ module.exports = {
const node = new Node(opts.repoPath || tempDir(), opts, true)

if (typeof opts.init === 'boolean' && opts.init === false) {
done(null, node)
process.nextTick(() => {
done(null, node)
})
} else {
node.init(err => {
if (err) {
return done(err)
}
done(null, node)
done(err, node)
})
}
}
Expand Down