fix(expo): address deprecation warning seen upon using @nrwl/expo:start (#14095)
This commit is contained in:
parent
d5c93bfa39
commit
217d6e3886
@ -1,6 +1,6 @@
|
||||
import { tmpdir } from 'os';
|
||||
import { join } from 'path';
|
||||
import * as fs from 'fs';
|
||||
import { existsSync, mkdirSync, removeSync, writeFileSync } from 'fs-extra';
|
||||
import { ensureNodeModulesSymlink } from './ensure-node-modules-symlink';
|
||||
|
||||
const workspaceDir = join(tmpdir(), 'nx-react-native-test');
|
||||
@ -9,19 +9,18 @@ const appDirAbsolutePath = join(workspaceDir, appDir);
|
||||
|
||||
describe('ensureNodeModulesSymlink', () => {
|
||||
beforeEach(() => {
|
||||
if (fs.existsSync(workspaceDir))
|
||||
fs.rmdirSync(workspaceDir, { recursive: true });
|
||||
fs.mkdirSync(workspaceDir);
|
||||
fs.mkdirSync(appDirAbsolutePath, { recursive: true });
|
||||
fs.mkdirSync(appDirAbsolutePath, { recursive: true });
|
||||
fs.writeFileSync(
|
||||
if (existsSync(workspaceDir)) removeSync(workspaceDir);
|
||||
mkdirSync(workspaceDir);
|
||||
mkdirSync(appDirAbsolutePath, { recursive: true });
|
||||
mkdirSync(appDirAbsolutePath, { recursive: true });
|
||||
writeFileSync(
|
||||
join(appDirAbsolutePath, 'package.json'),
|
||||
JSON.stringify({
|
||||
name: 'myapp',
|
||||
dependencies: { 'react-native': '*' },
|
||||
})
|
||||
);
|
||||
fs.writeFileSync(
|
||||
writeFileSync(
|
||||
join(workspaceDir, 'package.json'),
|
||||
JSON.stringify({
|
||||
name: 'workspace',
|
||||
@ -36,8 +35,7 @@ describe('ensureNodeModulesSymlink', () => {
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
if (fs.existsSync(workspaceDir))
|
||||
fs.rmdirSync(workspaceDir, { recursive: true });
|
||||
if (existsSync(workspaceDir)) removeSync(workspaceDir);
|
||||
});
|
||||
|
||||
it('should create symlinks', () => {
|
||||
@ -64,7 +62,7 @@ describe('ensureNodeModulesSymlink', () => {
|
||||
});
|
||||
|
||||
it('should add packages listed in workspace package.json', () => {
|
||||
fs.writeFileSync(
|
||||
writeFileSync(
|
||||
join(workspaceDir, 'package.json'),
|
||||
JSON.stringify({
|
||||
name: 'workspace',
|
||||
@ -92,8 +90,8 @@ describe('ensureNodeModulesSymlink', () => {
|
||||
|
||||
function createNpmDirectory(packageName, version) {
|
||||
const dir = join(workspaceDir, `node_modules/${packageName}`);
|
||||
fs.mkdirSync(dir, { recursive: true });
|
||||
fs.writeFileSync(
|
||||
mkdirSync(dir, { recursive: true });
|
||||
writeFileSync(
|
||||
join(dir, 'package.json'),
|
||||
JSON.stringify({ name: packageName, version: version })
|
||||
);
|
||||
@ -102,7 +100,7 @@ describe('ensureNodeModulesSymlink', () => {
|
||||
|
||||
function expectSymlinkToExist(packageName) {
|
||||
expect(
|
||||
fs.existsSync(
|
||||
existsSync(
|
||||
join(appDirAbsolutePath, `node_modules/${packageName}/package.json`)
|
||||
)
|
||||
).toBe(true);
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { join } from 'path';
|
||||
import { platform } from 'os';
|
||||
import * as fs from 'fs';
|
||||
import { existsSync, removeSync, symlinkSync } from 'fs-extra';
|
||||
|
||||
/**
|
||||
* This function symlink workspace node_modules folder with app project's node_mdules folder.
|
||||
@ -15,7 +15,7 @@ export function ensureNodeModulesSymlink(
|
||||
projectRoot: string
|
||||
): void {
|
||||
const worksapceNodeModulesPath = join(workspaceRoot, 'node_modules');
|
||||
if (!fs.existsSync(worksapceNodeModulesPath)) {
|
||||
if (!existsSync(worksapceNodeModulesPath)) {
|
||||
throw new Error(`Cannot find ${worksapceNodeModulesPath}`);
|
||||
}
|
||||
|
||||
@ -23,8 +23,8 @@ export function ensureNodeModulesSymlink(
|
||||
// `mklink /D` requires admin privilege in Windows so we need to use junction
|
||||
const symlinkType = platform() === 'win32' ? 'junction' : 'dir';
|
||||
|
||||
if (fs.existsSync(appNodeModulesPath)) {
|
||||
fs.rmdirSync(appNodeModulesPath, { recursive: true });
|
||||
if (existsSync(appNodeModulesPath)) {
|
||||
removeSync(appNodeModulesPath);
|
||||
}
|
||||
fs.symlinkSync(worksapceNodeModulesPath, appNodeModulesPath, symlinkType);
|
||||
symlinkSync(worksapceNodeModulesPath, appNodeModulesPath, symlinkType);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user