/
githubmirror
/
strapi
Обзор
Документация
Войти
/
githubmirror
/
strapi
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
develop
packages/cli/cloud/src/utils/helpers.ts
45 строк
1 KB
Nico André
chore(lint): add non-blocking oxlint setup (#26923)
31 июл 2026, 16:56
Не верифицирован
31 июл 2026, 16:56
6469af3
Код
Авторство
О чём код?
import chalk from 'chalk'; import { has } from 'lodash/fp'; // TODO: Remove duplicated code by extracting to a shared package const assertCwdContainsStrapiProject = (name: string) => { const logErrorAndExit = () => { console.log( `You need to run ${chalk.yellow( `strapi ${name}` )} in a Strapi project. Make sure you are in the right directory.` ); process.exit(1); }; try { // eslint-disable-next-line @typescript-eslint/no-var-requires const pkgJSON = require(`${process.cwd()}/package.json`); if ( !has('dependencies.@strapi/strapi', pkgJSON) && !has('devDependencies.@strapi/strapi', pkgJSON) ) { logErrorAndExit(); } } catch { logErrorAndExit(); } }; const runAction = (name: string, action: (...args: any[]) => Promise<unknown>) => (...args: unknown[]) => { assertCwdContainsStrapiProject(name); Promise.resolve() .then(() => { return action(...args); }) .catch((error) => { console.error(error); process.exit(1); }); }; export { runAction };