Skip to content

Commit

Permalink
🆕 Support packages outside of traditional root
Browse files Browse the repository at this point in the history
  • Loading branch information
steelbrain committed Dec 3, 2015
1 parent b54ad7a commit f5f655c
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions lib/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,28 @@

import {BufferedProcess} from 'atom'
const extractionRegex = /Installing (.*?) to .* (.*)/
const nameRegex = /(\\|\/)packages(\\|\/)(.*?)(\\|\/)/
const nameRegexes = [
/(\\|\/)packages(\\|\/)(.*?)(\\|\/)/,
/(\\|\/)([\w-_]+)(\\|\/)(lib|src)(\\|\/)/i,
/(\\|\/)([\w-_]+)(\\|\/)[\w-_]+\..+$/
]

export function guessName(filePath) {
const matches = nameRegex.exec(filePath)
return matches ? matches[3] : null
let matches

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

export function installPackages(dependencies, progressCallback) {
Expand Down

0 comments on commit f5f655c

Please sign in to comment.