From 6a984301191022717cde29a7641ad3cb8ab8b219 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 --- packages/js/src/executors/tsc/tsc.impl.ts | 13 +++++++++---- packages/js/src/generators/library/library.ts | 5 ++++- .../generators/release-version/release-version.ts | 4 ++-- .../utils/resolve-version-spec.spec.ts | 5 ++--- 4 files changed, 17 insertions(+), 10 deletions(-) diff --git a/packages/js/src/executors/tsc/tsc.impl.ts b/packages/js/src/executors/tsc/tsc.impl.ts index 8e668c8e1db55..9cf51138b57c7 100644 --- a/packages/js/src/executors/tsc/tsc.impl.ts +++ b/packages/js/src/executors/tsc/tsc.impl.ts @@ -1,5 +1,10 @@ import * as ts from 'typescript'; -import { ExecutorContext, isDaemonEnabled, output } from '@nx/devkit'; +import { + ExecutorContext, + isDaemonEnabled, + joinPathFragments, + output, +} from '@nx/devkit'; import type { TypeScriptCompilationOptions } from '@nx/workspace/src/utilities/typescript/compilation'; import { CopyAssetsHandler } from '../../utils/assets/copy-assets-handler'; import { checkDependencies } from '../../utils/check-dependencies'; @@ -41,11 +46,11 @@ export function createTypeScriptCompilationOptions( context: ExecutorContext ): TypeScriptCompilationOptions { return { - outputPath: normalizedOptions.outputPath, + outputPath: joinPathFragments(normalizedOptions.outputPath), projectName: context.projectName, projectRoot: normalizedOptions.projectRoot, - rootDir: normalizedOptions.rootDir, - tsConfig: normalizedOptions.tsConfig, + rootDir: joinPathFragments(normalizedOptions.rootDir), + tsConfig: joinPathFragments(normalizedOptions.tsConfig), watch: normalizedOptions.watch, deleteOutputPath: normalizedOptions.clean, getCustomTransformers: getCustomTrasformersFactory( diff --git a/packages/js/src/generators/library/library.ts b/packages/js/src/generators/library/library.ts index 4efc7a7e3d9ab..f7d08fb8b1d32 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 2a6205fbf7eb1..059031d435baa 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 72c95886ed3e7..61e0df61ca8f6 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')); }); });