Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (/!.*/.test(input)) {
const options = commands.map(command => ({
title: command.meta.name,
subtitle: `${command.meta.help} | Usage: ${command.meta.usage}`,
autocomplete: command.meta.autocomplete,
text: {
largetype: `${command.meta.help} | Usage: ${command.meta.usage}`
},
icon: command.meta.icon,
valid: false
}))
return alfy.inputMatches(options, 'title')
}
}
if (!alfy.cache.get('start-PID')) {
alfy.cache.set('start-PID', process.pid, {maxAge: 30000}) // 30 sec.
}
(async () => {
if (alfy.config.get('theme') === undefined) {
alfy.config.set('theme', 'dark')
}
try {
if (alfy.cache.get('start-PID') === process.pid) {
await runApplescript(`
tell application "Alfred 4"
run trigger ¬
"refresh" in workflow ¬
"org.bikenik.anki"
end tell
}
}
// No matches, show all commands
if (/!.*/.test(input)) {
const options = commands.map(command => ({
title: command.meta.name,
subtitle: `${command.meta.help} | Usage: ${command.meta.usage}`,
autocomplete: command.meta.autocomplete,
text: {
largetype: `${command.meta.help} | Usage: ${command.meta.usage}`
},
icon: command.meta.icon,
valid: false
}))
return alfy.inputMatches(options, 'title')
}
if (input === '') {
const ankiModelExist = await modelExist()
if (ankiModelExist.message) {
throw new WorkflowError('Decks was not found, check your Anki profile', errorAction('modelExist'))
}
const ankiDecks = await decks()
if (ankiDecks === null) {
throw new WorkflowError('Decks was not found, check your Anki profile', errorAction('profile'))
}
jsonfile.writeFile(fileAnkiDecks, ankiDecks, {
spaces: 2
}, err => {
languagePair.delete('target');
languagePair.set('pair', pair);
items.push({
title: `Success, [${q}] assigned.`
});
}
}
} else {
// manual
var pair = q.split('>');
if (pair.length !== 2) {
items.push({
title: `Failure, \'>\' must contain only one.`,
subtitle: `configuration format: source>target or first one&the second.`,
icon: {
path: alfy.icon.error
}
});
} else {
var pair0 = language.getCode(pair[0]);
var pair1 = language.getCode(pair[1]);
if (!pair0 && !pair1) {
items.push({
title: `Failure, source[${pair[0]}] and target[${pair[1]}] languages not supported.`,
subtitle: `Press shift to see full support languages.`,
quicklookurl: 'https://github.com/xfslove/alfred-language-configuration#readme',
icon: {
path: alfy.icon.error
}
});
} else if (!pair0) {
);
try {
if (fs.existsSync(customisationFilePath)) {
const additionalProducts = JSON.parse(
fs.readFileSync(customisationFilePath).toString()
);
if (additionalProducts[product.key]) {
product = {
...product,
...additionalProducts[product.key]
};
}
}
} catch (e) {
// die silently
if (alfy.debug) {
console.error(e);
}
}
}
return product;
};
process.env.HOME,
process.env.jb_search_customisation_file
);
try {
if (fs.existsSync(customisationFilePath)) {
const customSearchOptions = JSON.parse(
fs.readFileSync(customisationFilePath).toString()
);
fuseOptions = {
...fuseOptions,
...customSearchOptions
};
}
} catch (e) {
// die silently
if (alfy.debug) {
console.error(e);
}
}
}
return fuseOptions;
};
subtitle: `标准翻译结果: ${item}`,
arg: Name(item),
});
});
// 网络翻译结果
if (Result.web) {
let WebResult = Result.web;
WebResult.map((item) => {
ResultValueArr.push({
title: Name(item.value[0]),
subtitle: `其他翻译结果:${Name(item.value[0])}`,
arg: Name(item.value[0]),
});
})
}
alfy.output(ResultValueArr);
} else {
alfy.output(ErrResult);
}
});
},
'use strict';
const alfy = require('alfy');
const got = require('got');
const Rx = require('rxjs/Rx');
const utils = require('./utils');
const idx = parseInt(alfy.input, 10);
const status = idx < 0 ? alfy.config.get('custom') : utils.makeOutput()[idx];
const title = status.title === utils.REMOVE_STATUS ? '' : status.title;
const tokens = alfy.config.get('tokens') || {};
const sources = Object.keys(tokens).map(key => {
const baseUrl = 'https://slack.com/api/users.profile.set';
const options = {
method: 'get',
query: {
/* eslint camelcase: ["error", {properties: "never"}] */
token: tokens[key],
profile: JSON.stringify({
status_text: title,
status_emoji: status.emoji
})
}
};
doTranslate({
text: alfy.input,
from: {
language: 'auto',
ttsfile: os.tmpdir() + '/' + uuidv4() + ".mp3"
},
to: {
language: 'en',
ttsfile: os.tmpdir() + '/' + uuidv4() + ".mp3"
}
});
return;
}
// language detect
translator
.translate(alfy.input, {
from: 'auto',
to: 'en',
domain: g_config.domain,
client: 'gtx'
})
.then(function (res) {
var detect = res.from.language.iso;
var from = 'auto';
var to = 'en';
if (pair0 === detect) {
from = pair0;
to = pair1;
} else if (pair1 === detect) {
from = pair1;
to = pair0;
}
if (!results.length) {
results = nothingFound;
}
return results;
}
if (ALWAYS_OFFLINE) {
return alfy.output(getOfflineEmoji());
}
return alfy
.fetch("emoji.getdango.com/api/emoji", {
maxAge: 8640000000, // cache for 24 hours
query: {
q: alfy.input,
syn: 1
}
})
.then(({ results, synonyms = [] } = {}) => {
if (!results) {
return alfy.output(nothingFound);
}
return alfy.output([...new Set([...synonyms, ...results.map(({ text }) => text)])].map(format));
})
.catch(() => {
alfy.output(getOfflineEmoji())
});
};
const alfy = require('alfy')
const utils = require('./lib/utils')
const promises = []
const items = []
// teams config
const teams = alfy.config.get('figma.teams') ? JSON.parse(alfy.config.get('figma.teams')) : []
const isAddingTeam = alfy.input.match(/^add\shttps:\/\/www\.figma\.com\/files\/team\/(\d+)\/([^\/]+)/i)
if(isAddingTeam) {
return alfy.output([{
title: isAddingTeam[2],
subtitle: `Add ${isAddingTeam[2]} team’s project files to your search results.`,
arg: JSON.stringify({id: isAddingTeam[1], name: isAddingTeam[2]}),
variables: {
action: 'add',
notification: `${isAddingTeam[2]} team’s projects and files added to search results.`
}
}])
}
Promise.all(teams.map(team => {
return Promise.resolve(items.push({