Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use atom package path #36

Merged
merged 6 commits into from
Feb 8, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
language: objective-c

notifications:
email:
on_success: never
Expand All @@ -12,6 +10,26 @@ git:

sudo: false

os:
- linux
- osx

env:
global:
- APM_TEST_PACKAGES=""

matrix:
- ATOM_CHANNEL=stable
- ATOM_CHANNEL=beta

addons:
apt:
packages:
- build-essential
- git
- libgnome-keyring-dev
- fakeroot

branches:
only:
- master
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
### 3.0.6

* Use `atom-package-path` to determine caller package name

### 3.0.7

* Simplify the regex used (reduce more than 50% regex steps)
Expand Down
23 changes: 0 additions & 23 deletions lib/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,6 @@

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

export function guessName(filePath) {
let matches

matches = nameRegexes[0].exec(filePath)
if (matches) {
return matches[1]
}
matches = nameRegexes[1].exec(filePath)
if (matches) {
return matches[1]
}
matches = nameRegexes[2].exec(filePath)
if (matches) {
return matches[1]
}
return 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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@
},
"homepage": "https://github.com/AtomLinter/package-deps#readme",
"dependencies": {
"sb-callsite": "^1.0.0"
"atom-package-path": "^1.0.1"
}
}
17 changes: 0 additions & 17 deletions spec/package-deps-spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -88,20 +88,3 @@ describe 'Package-Deps', ->
expect(atom.packages.activatePackage.callCount).toBe(3)
expect(view.show.callCount).toBe(1)
expect(view.advance.callCount).toBe(2)

describe 'helpers', ->

describe 'guessName', ->
Helpers = require('../lib/helpers')

it 'works for packages in the correct place', ->
expect(Helpers.guessName('/home/steel/.atom/packages/linter/lib/main.js')).toBe('linter')
expect(Helpers.guessName('C:\\Users\\Steel Brain\\.atom\\packages\\linter\\lib\\main.js')).toBe('linter')

it 'works for packages that use the lib or src folder', ->
expect(Helpers.guessName('/home/steel/github/linter/lib/main.js')).toBe('linter')
expect(Helpers.guessName('C:\\Users\\Steel Brain\\github\\linter\\lib\\main.js')).toBe('linter')

it 'works for packages that have the main file in root folder', ->
expect(Helpers.guessName('/home/steel/github/linter/main.js')).toBe('linter')
expect(Helpers.guessName('C:\\Users\\Steel Brain\\github\\linter\\main.js')).toBe('linter')