Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

Commit

Permalink
fix(files:add): simplify checkPath
Browse files Browse the repository at this point in the history
  • Loading branch information
dignifiedquire committed May 9, 2016
1 parent aae2259 commit 46d9e6a
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions src/cli/commands/files/add.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,14 @@ function checkPath (inPath, recursive) {
throw new Error('Error: Argument \'path\' is required')
}

var s = fs.statSync(inPath)

if (s.isDirectory() && recursive === false) {
throw new Error('Error: ' + process.cwd() + ' is a directory, use the \'-r\' flag to specify directories')
}
if (inPath === '.' && recursive === true) {
if (inPath === '.') {
inPath = process.cwd()
} else if (inPath === '.' && recursive === false) {
s = fs.statSync(process.cwd())
if (s.isDirectory()) {
throw new Error('Error: ' + process.cwd() + ' is a directory, use the \'-r\' flag to specify directories')
}
}

if (fs.statSync(inPath).isDirectory() && recursive === false) {
throw new Error(`Error: ${inPath} is a directory, use the '-r' flag to specify directories`)
}

return inPath
}

Expand Down

0 comments on commit 46d9e6a

Please sign in to comment.