Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const requireOrExit = (file) => {
try {
return require(file)
} catch (e) {
error(e)
process.exit(1)
}
}
return new Promise((resolve, _reject) => {
if (!clientId || !secret) {
alfy.error('OAuth2 not set. Refer to README for details');
} else {
const accessToken = alfy.cache.get(ACCESS_TOKEN);
if (accessToken) {
resolve(bitbucket(accessToken));
} else {
console.log({ OPTIONS })
alfy.fetch(URL, OPTIONS).then(({ access_token }) => {
alfy.cache.set(ACCESS_TOKEN, access_token, { maxAge: ALIVE_TIME });
resolve(bitbucket(access_token));
}).catch(() => {
alfy.cache.set(ACCESS_TOKEN, null);
});
}
}
});
};
async function main() {
try {
const { name, version, gzip, size } = await getPackageStats(alfy.input);
alfy.output([
{
title: `${name}@${version}`,
subtitle: `Size: ${formatBytes(size)}, Gzip: ${formatBytes(
gzip
)}`,
arg: `https://bundlephobia.com/result?p=${name}@${version}`,
quicklookurl: `https://bundlephobia.com/result?p=${name}@${version}`
}
]);
} catch (e) {
alfy.error(e.message);
}
}
debug.addTimeItem(
matchItems,
`Match Projects: ${matchTime - projectsTime}ms`
);
if (matchItems.length) {
alfy.output(matchItems);
} else {
alfy.error(`No matching project for ${query}`);
}
} else {
alfy.output(items);
}
} else {
alfy.error("No project found");
}
(async () => {
const data = await alfy.fetch('https://api.douban.com/v2/movie/search', {
query: {
q: encodeURI(alfy.input),
},
});
if (!data.subjects) {
alfy.error(new Error(`API request failed`));
return;
}
if (data.subjects.length === 0) {
alfy.output([
{
title: `No movie found ${alfy.input}`,
subtitle: 'Click to see the result for yourself',
arg: `https://www.douban.com/search?cat=1002&q=${alfy.input}`,
},
]);
return;
}
alfy.output(
data.subjects.map(item => {