Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: File separator issue on Windows causing error: jest: got error running globalsetup cannot find module @angular\compiler-cli #2079

Merged
merged 2 commits into from
May 9, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions src/utils/ngcc-jest-processor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import { spawnSync } from 'child_process';
import path from 'path';

const ANGULAR_COMPILER_CLI_PKG_NAME = `@angular${path.sep}compiler-cli`;
const ANGULAR_COMPILER_CLI_PKG_NAME = '@angular/compiler-cli';
let ngccPath = '';

try {
Expand All @@ -20,13 +20,14 @@ try {
}
}
function findNodeModulesDirectory(): string {
return ngccPath.substring(0, ngccPath.indexOf(ANGULAR_COMPILER_CLI_PKG_NAME));
return ngccPath.substring(0, ngccPath.indexOf(ANGULAR_COMPILER_CLI_PKG_NAME.replace('/', path.sep)));
}

function findAngularCompilerCliVersion(): string {
const path = require.resolve(ANGULAR_COMPILER_CLI_PKG_NAME);
const substringLength = path.indexOf(ANGULAR_COMPILER_CLI_PKG_NAME) + ANGULAR_COMPILER_CLI_PKG_NAME.length;
const ngCompilerCliFolder = path.substring(0, substringLength);
const packagePath = require.resolve(ANGULAR_COMPILER_CLI_PKG_NAME);
const substringLength =
packagePath.indexOf(ANGULAR_COMPILER_CLI_PKG_NAME.replace('/', path.sep)) + ANGULAR_COMPILER_CLI_PKG_NAME.length;
const ngCompilerCliFolder = packagePath.substring(0, substringLength);
const ngCompilerCliPackageJson = `${ngCompilerCliFolder}/package.json`;
// eslint-disable-next-line @typescript-eslint/no-var-requires
const { version } = require(ngCompilerCliPackageJson);
Expand Down