-
Notifications
You must be signed in to change notification settings - Fork 67
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
The big refactor! #200
The big refactor! #200
Changes from 1 commit
012c327
5040d41
df9ffa0
caca0e2
d72ab8a
06f70a2
2582dbf
9f6632c
56c618e
b0da61a
a9f6031
7c149a1
664d8ed
e476440
aab54af
fc49b3b
c8083df
8ff1976
2a00842
37194d3
7ee051f
97ab8ed
581945e
4d87386
8cc19eb
12ef363
63f5243
5738822
bea0caf
1463b98
19a4133
ce7b68c
d2f8680
d9ada2e
dd20ef7
30c25c6
f9d3eb4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
|
||
const defaults = require('lodash.defaultsdeep') | ||
const clone = require('lodash.clone') | ||
const waterfall = require('async/waterfall') | ||
const series = require('async/series') | ||
const path = require('path') | ||
const tmpDir = require('./utils/tmp-dir') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This brought the os module to the browser. |
||
|
||
|
@@ -101,9 +101,12 @@ class FactoryInProc { | |
? options.init | ||
: true | ||
|
||
if (!options.disposable) { | ||
if (options.disposable) { | ||
options.config = defaults({}, options.config, defaultConfig) | ||
} else { | ||
const nonDisposableConfig = clone(defaultConfig) | ||
delete nonDisposableConfig.Addresses | ||
// TODO why delete the addrs here??? | ||
// delete nonDisposableConfig.Addresses | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @dryajov why were you deleting the addrs here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because at some point we wanted non-disposable nodes to use |
||
|
||
options.init = false | ||
options.start = false | ||
|
@@ -115,32 +118,25 @@ class FactoryInProc { | |
|
||
options.repoPath = options.repoPath || (process.env.IPFS_PATH || defaultRepo) | ||
options.config = defaults({}, options.config, nonDisposableConfig) | ||
} else { | ||
options.config = defaults({}, options.config, defaultConfig) | ||
} | ||
|
||
let node | ||
options.type = this.type | ||
options.exec = options.exec || this.exec | ||
|
||
if (typeof options.exec !== 'function') { | ||
return callback(new Error(`'type' proc requires 'exec' to be a coderef`)) | ||
} | ||
|
||
node = new Node(options) | ||
const node = new Node(options) | ||
|
||
waterfall([ | ||
series([ | ||
(cb) => options.init | ||
? node.init(cb) | ||
: cb(null, node), | ||
(node, cb) => options.start | ||
: cb(), | ||
(cb) => options.start | ||
? node.start(options.args, cb) | ||
: cb() | ||
], (err) => { | ||
if (err) { return callback(err) } | ||
|
||
callback(null, node) | ||
}) | ||
], (err) => callback(err, node)) | ||
} | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why duplicate if factory-in-proc share %90+ code with factory-daemon?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should have a base class then. The main reason is that you want to avoid having factory-daemon being loaded in the browser (and all of its dependencies).