-
Notifications
You must be signed in to change notification settings - Fork 1.3k
files add, cat, get core + cli offline #193
Conversation
throw new Error('Error: Argument \'path\' is required') | ||
} | ||
|
||
s = fs.statSync(path) |
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.
You could declare s
here where it's needed instead of at the top
if (s.isDirectory()) { | ||
throw new Error('Error: ' + process.cwd() + ' is a directory, use the \'-r\' flag to specify directories') | ||
} | ||
} |
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.
What is the goal of this chunk of code? Can it be extracted to a function with a good name? At first glance seems madness to me :D
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.
It's to check for all of the inputs you could give to add command. variations i could think of are...
- "." add the cwd but throw error for no recursion flag
- "." -r add the cwd
- "/some/path" but throw error for no recursion
- "/some/path" -r
- No path, throw err
- filename.type
I could make a checkpath() function but i'm not sure how that would simplify any of the logic
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.
Creating a function and adding that as a comment describing what it is doing would be considerably much better.
CR'ed 👍 left some comments that can be applied through the code. Cool that things are going :D |
No description provided.