Skip to content
This repository was archived by the owner on Aug 11, 2021. It is now read-only.

Commit ac4a9e3

Browse files
ZJONSSONzkat
authored andcommitted
Move props.path check below class init (#55)
`self.error` is not available until the prototype is available PR-URL: #55 Credit: @ZJONSSON Reviewed-By: @zkat
1 parent 24fabde commit ac4a9e3

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

Diff for: lib/reader.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,6 @@ function Reader (props, currentStat) {
2121
props = { path: props }
2222
}
2323

24-
if (!props.path) {
25-
self.error('Must provide a path', null, true)
26-
}
27-
2824
// polymorphism.
2925
// call fstream.Reader(dir) to get a DirReader object, etc.
3026
// Note that, unlike in the Writer case, ProxyReader is going
@@ -85,6 +81,10 @@ function Reader (props, currentStat) {
8581

8682
Abstract.call(self)
8783

84+
if (!props.path) {
85+
self.error('Must provide a path', null, true)
86+
}
87+
8888
self.readable = true
8989
self.writable = false
9090

Diff for: lib/writer.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ function Writer (props, current) {
3030
props = { path: props }
3131
}
3232

33-
if (!props.path) self.error('Must provide a path', null, true)
34-
3533
// polymorphism.
3634
// call fstream.Writer(dir) to get a DirWriter object, etc.
3735
var type = getType(props)
@@ -61,6 +59,8 @@ function Writer (props, current) {
6159

6260
Abstract.call(self)
6361

62+
if (!props.path) self.error('Must provide a path', null, true)
63+
6464
// props is what we want to set.
6565
// set some convenience properties as well.
6666
self.type = props.type

0 commit comments

Comments
 (0)