alfred-polyglot
Advanced tools
Comparing version 1.1.1 to 1.1.2
58
index.js
@@ -7,35 +7,35 @@ const alfredNotifier = require('alfred-notifier') | ||
alfredNotifier() | ||
alfredNotifier(); | ||
workflow(alfy.input).then(out => { | ||
if (out === null) { | ||
throw new WorkflowError('Something went wrong :(') | ||
} | ||
(async () => { | ||
try { | ||
const out = await workflow(alfy.input) | ||
alfy.output(out) | ||
}).catch(err => { | ||
err = err || {} | ||
if (out === null) { | ||
throw new WorkflowError('Something went wrong :(') | ||
} | ||
} catch (err) { | ||
const messages = [] | ||
const messages = [] | ||
if (err.tip) { | ||
messages.push(err.tip) | ||
} | ||
if (err.tip) { | ||
messages.push(err.tip) | ||
messages.push('Activate this item to try again.') | ||
messages.push('⌘L to see the stack trace') | ||
alfy.output([{ | ||
title: `Error: ${err.message}`, | ||
subtitle: messages.join(' | '), | ||
autocomplete: err.autocomplete ? err.autocomplete : '', | ||
icon: { | ||
path: alfy.icon.error | ||
}, | ||
valid: false, | ||
text: { | ||
largetype: err.stack, | ||
copy: err.stack | ||
} | ||
}]) | ||
} | ||
messages.push('Activate this item to try again.') | ||
messages.push('⌘L to see the stack trace') | ||
alfy.output([{ | ||
title: `Error: ${err.message}`, | ||
subtitle: messages.join(' | '), | ||
autocomplete: err.autocomplete ? err.autocomplete : '', | ||
icon: { | ||
path: alfy.icon.error | ||
}, | ||
valid: false, | ||
text: { | ||
largetype: err.stack, | ||
copy: err.stack | ||
} | ||
}]) | ||
}) | ||
})() |
@@ -28,2 +28,3 @@ const alfy = require('alfy') | ||
subtitle: '⇒ ' + alfy.config.get(key), | ||
valid: false, | ||
autocomplete: `!set ${key} ` | ||
@@ -55,2 +56,3 @@ }) | ||
// eslint-disable-next-line prefer-destructuring | ||
const variableName = chunks[1] | ||
@@ -57,0 +59,0 @@ |
@@ -84,6 +84,4 @@ const alfy = require('alfy') | ||
let fromLangMsg = languages[res.from.language.iso] | ||
let toLangMsg = languages[to] | ||
const toLangMsg = languages[to] | ||
const output = [] | ||
if (res.from.language.didYouMean) { | ||
@@ -102,2 +100,4 @@ fromLangMsg += ` (corrected from ${languages[from]})` | ||
const output = [] | ||
const translateUrl = `https://translate.google.com/#${from}/${to}/${text}` | ||
@@ -130,3 +130,4 @@ output.push({ | ||
title: `Did you mean: '${corrected}'`, | ||
autocomplete: input.replace(text, corrected) | ||
autocomplete: input.replace(text, corrected), | ||
valid: false | ||
}) | ||
@@ -133,0 +134,0 @@ } |
class WorkflowError extends Error { | ||
constructor(message, data) { | ||
// data is an object with the following optional props: | ||
// .tip - message to show can the user fix the error | ||
// .autocomplete - self-explanatory | ||
// `data` is an object with the following optional props: | ||
// .tip - message to show so the user can fix the error | ||
// .autocomplete - self-explanatory | ||
@@ -7,0 +7,0 @@ super(message) |
@@ -17,3 +17,3 @@ const alfy = require('alfy') | ||
if (command.match(input)) { | ||
return await command(input) | ||
return command(input) | ||
} | ||
@@ -20,0 +20,0 @@ } |
@@ -15,2 +15,3 @@ const alfy = require('alfy') | ||
autocomplete: autocomplete(name), | ||
valid: false, | ||
icon: { | ||
@@ -17,0 +18,0 @@ path: `icons/${languages.getCode(name)}.png` |
{ | ||
"name": "alfred-polyglot", | ||
"version": "1.1.1", | ||
"version": "1.1.2", | ||
"description": "Translate text with ease using Google Translate", | ||
@@ -17,3 +17,4 @@ "license": "MIT", | ||
"postinstall": "alfy-init", | ||
"preuninstall": "alfy-cleanup" | ||
"preuninstall": "alfy-cleanup", | ||
"test": "xo" | ||
}, | ||
@@ -39,3 +40,3 @@ "files": [ | ||
"devDependencies": { | ||
"xo": "^0.17.0" | ||
"xo": "^0.20.3" | ||
}, | ||
@@ -42,0 +43,0 @@ "xo": { |
const alfy = require('alfy') | ||
const env = process.env | ||
const {env} = process.env | ||
alfy.config.set(env.config_variable, env.config_value) |
Sorry, the diff of this file is not supported yet
1243447
301