From b54ad7a33aacc18b35c97fe78a474fefc954b7c4 Mon Sep 17 00:00:00 2001 From: steelbrain Date: Wed, 2 Dec 2015 01:16:23 -0800 Subject: [PATCH 1/4] :fire: Remove an unnecessary dependency --- package.json | 3 --- 1 file changed, 3 deletions(-) diff --git a/package.json b/package.json index 8c87a34..f665350 100644 --- a/package.json +++ b/package.json @@ -19,9 +19,6 @@ "url": "https://github.com/AtomLinter/package-deps/issues" }, "homepage": "https://github.com/AtomLinter/package-deps#readme", - "devDependencies": { - "event-kit": "^1.3.0" - }, "dependencies": { "sb-callsite": "^1.0.0" } From f5f655c843f41a73403affbe2fcaf0f80470f0d3 Mon Sep 17 00:00:00 2001 From: steelbrain Date: Wed, 2 Dec 2015 18:39:22 -0700 Subject: [PATCH 2/4] :new: Support packages outside of traditional root --- lib/helpers.js | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/lib/helpers.js b/lib/helpers.js index 7c6cb4e..7de21c5 100644 --- a/lib/helpers.js +++ b/lib/helpers.js @@ -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) { From c05bb8597107280a31db6a199e12581e56810249 Mon Sep 17 00:00:00 2001 From: steelbrain Date: Wed, 2 Dec 2015 18:39:32 -0700 Subject: [PATCH 3/4] :new: Add specs for the change --- spec/package-deps-spec.coffee | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/spec/package-deps-spec.coffee b/spec/package-deps-spec.coffee index ba9e292..9ad04d1 100644 --- a/spec/package-deps-spec.coffee +++ b/spec/package-deps-spec.coffee @@ -94,7 +94,14 @@ describe 'Package-Deps', -> describe 'guessName', -> Helpers = require('../lib/helpers') - it 'works for nix', -> + it 'works for packages in the correct place', -> expect(Helpers.guessName('/home/steel/.atom/packages/linter/lib/main.js')).toBe('linter') - it 'works for windows', -> - expect(Helpers.guessName('C:\\Users\\Anees Iqbal\\.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') From a5b6d04c8aafb1bee801624b284671e3abef4eb0 Mon Sep 17 00:00:00 2001 From: steelbrain Date: Wed, 2 Dec 2015 18:40:03 -0700 Subject: [PATCH 4/4] :memo: Document change in CHANGELOG --- CHANGELOG.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fdcb644..1037d84 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,10 +1,14 @@ +### Upcoming + +* Supports guessing names of packages outside of main root + ### 3.0.5 * Replace Linux-specific dependency `callsite` with cross-platform `sb-callsite` ### 3.0.4 -* Fix a scenario when error would be thrown if package name guessign fails +* Fix a scenario when error would be thrown if package name guessing fails ### 3.0.3 @@ -38,7 +42,7 @@ ### 2.1.0 -* Introduced second parameter to install method +* Introduced second parameter to install method ### 2.0.x