alfred-plugin-projj
Advanced tools
1.1.0 / 2020-04-20 | ||
================== | ||
**fixes** | ||
* [[`8872980`](http://github.com/atian25/alfred-plugin-projj/commit/8872980d5f23729401ba197574c3b5fcce3759a6)] - fix: support projj 2.0 (#3) (DiamondYuan <<541832074@qq.com>>) | ||
**others** | ||
* [[`65f7416`](http://github.com/atian25/alfred-plugin-projj/commit/65f741610992c09955189503109b6299376976ac)] - refactor: splice (#4) (TZ | 天猪 <<atian25@qq.com>>) | ||
* [[`72c5c46`](http://github.com/atian25/alfred-plugin-projj/commit/72c5c46896ddfebfb0b26c17b3b850a3a8e6e9b0)] - chore: github actions (TZ | 天猪 <<atian25@qq.com>>) | ||
1.0.2 / 2019-03-19 | ||
@@ -3,0 +13,0 @@ ================== |
33
index.js
@@ -14,6 +14,7 @@ 'use strict'; | ||
// read config | ||
const homeDir = alfy.config.get('HOME') || homedir(); | ||
const homeDir = alfy.config.get('HOME') || /* istanbul ignore next */ homedir(); | ||
const cfgPath = path.join(homeDir, '.projj/config.json'); | ||
const cachePath = path.join(homeDir, '.projj/cache.json'); | ||
/* istanbul ignore else */ | ||
if (await fs.exists(cfgPath)) { | ||
@@ -25,2 +26,3 @@ cfg = require(cfgPath); | ||
/* istanbul ignore else */ | ||
if (await fs.exists(cachePath)) { | ||
@@ -35,11 +37,24 @@ cache = require(cachePath); | ||
const title = key.substring(key.indexOf('/') + 1); | ||
const filePath = path.join(cfg.base, key); | ||
const [ host, ...repository ] = key.split('/').splice(-3); | ||
const title = repository.join('/'); | ||
let filePath; | ||
if (Array.isArray(cfg.base)) { | ||
filePath = key; | ||
} else { | ||
if (!key.startsWith(cfg.base)) { | ||
filePath = path.join(cfg.base, key); | ||
} else { | ||
filePath = key; | ||
} | ||
} | ||
// icon | ||
let type; | ||
if (key.startsWith('github.com')) { | ||
if (host.startsWith('github.com')) { | ||
type = 'github'; | ||
} else if (key.startsWith('gitlab')) { | ||
} else if (host.startsWith('gitlab')) { | ||
type = 'gitlab'; | ||
} else { | ||
type = 'git'; | ||
} | ||
@@ -54,8 +69,8 @@ | ||
alt: { | ||
arg: `https://${key}`, | ||
subtitle: `open in browser`, | ||
arg: `https://${host}/${title}`, | ||
subtitle: 'open in browser', | ||
}, | ||
cmd: { | ||
arg: filePath, | ||
subtitle: `open in iTerm`, | ||
subtitle: 'open in iTerm', | ||
}, | ||
@@ -73,3 +88,3 @@ }, | ||
} else { | ||
alfy.output([ { title: `not match git project \`${alfy.input}\`` }]); | ||
alfy.output([{ title: `not match git project \`${alfy.input}\`` }]); | ||
} | ||
@@ -76,0 +91,0 @@ } |
{ | ||
"name": "alfred-plugin-projj", | ||
"version": "1.0.2", | ||
"version": "1.1.0", | ||
"description": "alfred plugin for https://github.com/popomore/projj", | ||
"dependencies": { | ||
"alfy": "^0.8.0", | ||
"alfy": "^0.9.1", | ||
"mz": "^2.7.0", | ||
@@ -11,8 +11,7 @@ "node-homedir": "^1.1.1" | ||
"devDependencies": { | ||
"alfy-test": "^0.3.0", | ||
"autod": "^3.0.1", | ||
"egg-bin": "^4.11.1", | ||
"egg-ci": "^1.11.0", | ||
"eslint": "^5.15.3", | ||
"eslint-config-egg": "^7.2.0" | ||
"alfy-test": "^0.4.0", | ||
"autod": "^3.1.0", | ||
"egg-bin": "^4.14.1", | ||
"eslint": "^6.8.0", | ||
"eslint-config-egg": "^8.0.1" | ||
}, | ||
@@ -33,5 +32,2 @@ "engines": { | ||
}, | ||
"ci": { | ||
"version": "10" | ||
}, | ||
"eslintIgnore": [ | ||
@@ -38,0 +34,0 @@ "coverage", |
397102
0.57%5
-16.67%10
11.11%76
22.58%