How to use the alfy.error function in alfy

To help you get started, we’ve selected a few alfy examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github exah / alfred-hotel / index.js View on Github external
const requireOrExit = (file) => {
  try {
    return require(file)
  } catch (e) {
    error(e)
    process.exit(1)
  }
}
github nicklayb / alfred-bitbucket / authenticate.js View on Github external
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);
                });
            }
        }
    });
};
github prashantpalikhe / alfred-bundlephobia / index.js View on Github external
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);
	}
}
github bchatard / alfred-jetbrains / src / index.js View on Github external
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");
}
github sorrycc / alfred-douban / index.js View on Github external
(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 => {