From 91ad3f06da898c2c804666a86402302d945ce3cd Mon Sep 17 00:00:00 2001 From: robertIsaac Date: Mon, 5 Aug 2024 19:43:52 +0300 Subject: [PATCH] fix(js): tests on windows --- .../js/src/executors/tsc/lib/normalize-options.ts | 11 ++++++----- packages/js/src/generators/library/library.ts | 5 ++++- .../src/generators/release-version/release-version.ts | 4 ++-- .../utils/resolve-version-spec.spec.ts | 5 ++--- 4 files changed, 14 insertions(+), 11 deletions(-) diff --git a/packages/js/src/executors/tsc/lib/normalize-options.ts b/packages/js/src/executors/tsc/lib/normalize-options.ts index c5fd466821c220..6a50786faaecb3 100644 --- a/packages/js/src/executors/tsc/lib/normalize-options.ts +++ b/packages/js/src/executors/tsc/lib/normalize-options.ts @@ -1,4 +1,4 @@ -import { join, resolve } from 'path'; +import { resolve } from 'path'; import type { ExecutorOptions, NormalizedExecutorOptions, @@ -7,6 +7,7 @@ import { FileInputOutput, assetGlobsToFiles, } from '../../../utils/assets/assets'; +import { joinPathFragments } from 'nx/src/utils/path'; export function normalizeOptions( options: ExecutorOptions, @@ -14,10 +15,10 @@ export function normalizeOptions( sourceRoot: string, projectRoot: string ): NormalizedExecutorOptions { - const outputPath = join(contextRoot, options.outputPath); + const outputPath = joinPathFragments(contextRoot, options.outputPath); const rootDir = options.rootDir - ? join(contextRoot, options.rootDir) - : join(contextRoot, projectRoot); + ? joinPathFragments(contextRoot, options.rootDir) + : joinPathFragments(contextRoot, projectRoot); if (options.watch == null) { options.watch = false; @@ -50,7 +51,7 @@ export function normalizeOptions( projectRoot, files, outputPath, - tsConfig: join(contextRoot, options.tsConfig), + tsConfig: joinPathFragments(contextRoot, options.tsConfig), rootDir, mainOutputPath: resolve( outputPath, diff --git a/packages/js/src/generators/library/library.ts b/packages/js/src/generators/library/library.ts index 4efc7a7e3d9ab8..f7d08fb8b1d321 100644 --- a/packages/js/src/generators/library/library.ts +++ b/packages/js/src/generators/library/library.ts @@ -251,7 +251,10 @@ async function addProject(tree: Tree, options: NormalizedSchema) { } if (options.publishable) { - const packageRoot = join(defaultOutputDirectory, '{projectRoot}'); + const packageRoot = joinPathFragments( + defaultOutputDirectory, + '{projectRoot}' + ); projectConfiguration.targets ??= {}; projectConfiguration.targets['nx-release-publish'] = { diff --git a/packages/js/src/generators/release-version/release-version.ts b/packages/js/src/generators/release-version/release-version.ts index 2a6205fbf7eb1f..059031d435baa1 100644 --- a/packages/js/src/generators/release-version/release-version.ts +++ b/packages/js/src/generators/release-version/release-version.ts @@ -140,7 +140,7 @@ Valid values are: ${validReleaseVersionPrefixes ); } - const packageJsonPath = join(packageRoot, 'package.json'); + const packageJsonPath = joinPathFragments(packageRoot, 'package.json'); if (!tree.exists(packageJsonPath)) { throw new Error( `The project "${projectName}" does not have a package.json available at ${packageJsonPath}. @@ -830,7 +830,7 @@ To fix this you will either need to add a package.json file at that location, or `The project "${dependencyProjectName}" does not have a packageRoot available. Please report this issue on https://github.com/nrwl/nx` ); } - const dependencyPackageJsonPath = join( + const dependencyPackageJsonPath = joinPathFragments( dependencyPackageRoot, 'package.json' ); diff --git a/packages/js/src/generators/release-version/utils/resolve-version-spec.spec.ts b/packages/js/src/generators/release-version/utils/resolve-version-spec.spec.ts index 72c95886ed3e72..61e0df61ca8f65 100644 --- a/packages/js/src/generators/release-version/utils/resolve-version-spec.spec.ts +++ b/packages/js/src/generators/release-version/utils/resolve-version-spec.spec.ts @@ -1,4 +1,3 @@ -import { join } from 'path'; import { resolveVersionSpec } from './resolve-version-spec'; describe('resolveVersionSpec()', () => { @@ -67,7 +66,7 @@ describe('resolveVersionSpec()', () => { 'file:../projectB', '/packages/projectB' ) - ).toEqual(expect.stringContaining(join('/packages/projectB'))); + ).toEqual(expect.stringContaining('/packages/projectB')); }); it('should work for a yarn classic style link reference', async () => { @@ -78,6 +77,6 @@ describe('resolveVersionSpec()', () => { 'link:../projectB', '/packages/projectB' ) - ).toEqual(expect.stringContaining(join('/packages/projectB'))); + ).toEqual(expect.stringContaining('/packages/projectB')); }); });