UNPKG

@nx/expo

Version:

The Expo Plugin for Nx contains executors and generators for managing and developing an expo application within your workspace. For example, you can directly build for different target platforms as well as generate projects and publish your code.

28 lines (27 loc) 1.51 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ensureNodeModulesSymlink = ensureNodeModulesSymlink; const node_fs_1 = require("node:fs"); const os_1 = require("os"); const path_1 = require("path"); /** * This function symlink workspace node_modules folder with app project's node_mdules folder. * For yarn and npm, it will symlink the entire node_modules folder. * If app project's node_modules already exist, it will remove it first then symlink it. * For pnpm, it will go through the package.json' dependencies and devDependencies, and also the required packages listed above. * @param workspaceRoot path of the workspace root * @param projectRoot path of app project root */ function ensureNodeModulesSymlink(workspaceRoot, projectRoot) { const worksapceNodeModulesPath = (0, path_1.join)(workspaceRoot, 'node_modules'); if (!(0, node_fs_1.existsSync)(worksapceNodeModulesPath)) { throw new Error(`Cannot find ${worksapceNodeModulesPath}`); } const appNodeModulesPath = (0, path_1.join)(workspaceRoot, projectRoot, 'node_modules'); // `mklink /D` requires admin privilege in Windows so we need to use junction const symlinkType = (0, os_1.platform)() === 'win32' ? 'junction' : 'dir'; if ((0, node_fs_1.existsSync)(appNodeModulesPath)) { (0, node_fs_1.rmSync)(appNodeModulesPath, { recursive: true, force: true }); } (0, node_fs_1.symlinkSync)(worksapceNodeModulesPath, appNodeModulesPath, symlinkType); }