Skip to content

Commit

Permalink
🎨 Use atom-package-path to determine caller package name
Browse files Browse the repository at this point in the history
  • Loading branch information
steelbrain committed Feb 8, 2016
1 parent 6ad2622 commit 8aa6afc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 12 deletions.
6 changes: 0 additions & 6 deletions lib/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,6 @@

import {BufferedProcess} from 'atom'
const extractionRegex = /Installing (.*?) to .* (.*)/
const nameRegex = /(\\|\/)packages(\\|\/)(.*?)(\\|\/)/

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

export function installPackages(dependencies, progressCallback) {
return new Promise(function(resolve, reject) {
Expand Down
11 changes: 5 additions & 6 deletions lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,11 @@ if (typeof window.__steelbrain_package_deps === 'undefined') {

export function install(name = null, enablePackages = false) {
if (!name) {
const filePath = require('sb-callsite').capture()[1].file
name = guessName(filePath)
if (!name) {
console.log(`Unable to get package name for file: ${filePath}`)
return Promise.resolve()
}
name = require('atom-package-path').guess()
}
if (!name) {
console.log(`Unable to get package name for file: ${filePath}`)
return Promise.resolve()
}
const {toInstall, toEnable} = packagesToInstall(name)
let promise = Promise.resolve()
Expand Down

0 comments on commit 8aa6afc

Please sign in to comment.