Skip to content

Commit

Permalink
fix: file separator issue on Windows causing error in `ngcc-jest-proc…
Browse files Browse the repository at this point in the history
…essor` (#2079)
  • Loading branch information
pal03377 authored May 9, 2023
1 parent 30c0ba5 commit b6b3911
Showing 1 changed file with 6 additions and 5 deletions.
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

0 comments on commit b6b3911

Please sign in to comment.