@strapi/strapi
Version:
An open source headless CMS solution to create and manage your own API. It provides a powerful dashboard and features to make your life easier. Databases supported: MySQL, MariaDB, PostgreSQL, SQLite
31 lines (28 loc) • 1.15 kB
JavaScript
import path from 'node:path';
import { getModulePath } from './resolve-module.mjs';
const DESIGN_SYSTEM_MODULE = '@strapi/design-system';
/**
* Detect if a package is locally linked (portal:, file:, yarn link) rather than installed in node_modules.
* When linked, the resolved path is outside node_modules.
*
* @internal
*/ const isPackageLinked = (mod)=>{
const pkgRoot = getModulePath(mod);
const pathSegments = pkgRoot.split(path.sep);
return !pathSegments.includes('node_modules');
};
/**
* Detects if @strapi/design-system is linked (portal:, file:, or yarn link).
* Returns the package root path when linked, null otherwise.
* Uses the heuristic: linked packages resolve outside node_modules.
*/ const getLinkedDesignSystemPath = ()=>{
try {
const pkgRoot = getModulePath(DESIGN_SYSTEM_MODULE);
return isPackageLinked(DESIGN_SYSTEM_MODULE) ? pkgRoot : null;
} catch {
return null;
}
};
const isDesignSystemLinked = ()=>getLinkedDesignSystemPath() !== null;
export { getLinkedDesignSystemPath, isDesignSystemLinked, isPackageLinked };
//# sourceMappingURL=linked-packages.mjs.map