UNPKG

@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

35 lines (31 loc) 1.27 kB
'use strict'; var path = require('node:path'); var resolveModule = require('./resolve-module.js'); 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 = resolveModule.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 = resolveModule.getModulePath(DESIGN_SYSTEM_MODULE); return isPackageLinked(DESIGN_SYSTEM_MODULE) ? pkgRoot : null; } catch { return null; } }; const isDesignSystemLinked = ()=>getLinkedDesignSystemPath() !== null; exports.getLinkedDesignSystemPath = getLinkedDesignSystemPath; exports.isDesignSystemLinked = isDesignSystemLinked; exports.isPackageLinked = isPackageLinked; //# sourceMappingURL=linked-packages.js.map