Skip to content

Commit

Permalink
Merge pull request #33 from Arcanemagus/simplify-regex
Browse files Browse the repository at this point in the history
Simplify the regex used
  • Loading branch information
steelbrain committed Dec 3, 2015
2 parents c322a5c + 0f1b3d4 commit 1add0e6
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions lib/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,25 @@
import {BufferedProcess} from 'atom'
const extractionRegex = /Installing (.*?) to .* (.*)/
const nameRegexes = [
/(\\|\/)packages(\\|\/)(.*?)(\\|\/)/,
/(\\|\/)([\w-_]+)(\\|\/)(lib|src)(\\|\/)/i,
/(\\|\/)([\w-_]+)(\\|\/)[\w-_]+\..+$/
/[\\\/]packages[\\\/](.*?)[\\\/]/,
/[\\\/]([\w-_]+)[\\\/](?:lib|src)[\\\/]/i,
/[\\\/]([\w-_]+)[\\\/][\w-_]+\..+$/
]

export function guessName(filePath) {
let matches

matches = nameRegexes[0].exec(filePath)
if (matches) {
return matches[3]
return matches[1]
}
matches = nameRegexes[1].exec(filePath)
if (matches) {
return matches[2]
return matches[1]
}
matches = nameRegexes[2].exec(filePath)
if (matches) {
return matches[2]
return matches[1]
}
return null
}
Expand Down

0 comments on commit 1add0e6

Please sign in to comment.