diff --git a/.travis.yml b/.travis.yml index e54e090..5eb4922 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,3 @@ -language: objective-c - notifications: email: on_success: never @@ -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 diff --git a/CHANGELOG.md b/CHANGELOG.md index 793954f..b609a58 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/lib/helpers.js b/lib/helpers.js index a5e79a7..444af81 100644 --- a/lib/helpers.js +++ b/lib/helpers.js @@ -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) { diff --git a/lib/main.js b/lib/main.js index 1a9683f..d50956e 100644 --- a/lib/main.js +++ b/lib/main.js @@ -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() diff --git a/package.json b/package.json index ab946b1..9c4305a 100644 --- a/package.json +++ b/package.json @@ -20,6 +20,6 @@ }, "homepage": "https://github.com/AtomLinter/package-deps#readme", "dependencies": { - "sb-callsite": "^1.0.0" + "atom-package-path": "^1.0.1" } } diff --git a/spec/package-deps-spec.coffee b/spec/package-deps-spec.coffee index 9ad04d1..78f1c63 100644 --- a/spec/package-deps-spec.coffee +++ b/spec/package-deps-spec.coffee @@ -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')