Skip to content

Commit

Permalink
fix(js): tests on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
robertIsaac committed Aug 5, 2024
1 parent a3869a8 commit fb462fa
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 13 deletions.
11 changes: 6 additions & 5 deletions packages/js/src/executors/tsc/lib/normalize-options.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { join, resolve } from 'path';
import { resolve } from 'path';
import type {
ExecutorOptions,
NormalizedExecutorOptions,
Expand All @@ -7,17 +7,18 @@ import {
FileInputOutput,
assetGlobsToFiles,
} from '../../../utils/assets/assets';
import { joinPathFragments } from 'nx/src/utils/path';

export function normalizeOptions(
options: ExecutorOptions,
contextRoot: string,
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;
Expand Down Expand Up @@ -50,7 +51,7 @@ export function normalizeOptions(
projectRoot,
files,
outputPath,
tsConfig: join(contextRoot, options.tsConfig),
tsConfig: joinPathFragments(contextRoot, options.tsConfig),
rootDir,
mainOutputPath: resolve(
outputPath,
Expand Down
5 changes: 4 additions & 1 deletion packages/js/src/generators/library/library.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'] = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ Valid values are: ${validReleaseVersionPrefixes
);
}

const packageJsonPath = join(packageRoot, 'package.json');
const packageJsonPath = joinPathFragments(packageRoot, 'package.json');

const color = getColor(projectName);
const log = (msg: string) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { join } from 'path';
import { resolveVersionSpec } from './resolve-version-spec';
import { joinPathFragments } from 'nx/src/utils/path';

describe('resolveVersionSpec()', () => {
it('should work for specific name and spec', () => {
Expand Down Expand Up @@ -67,7 +67,7 @@ describe('resolveVersionSpec()', () => {
'file:../projectB',
'/packages/projectB'
)
).toEqual(expect.stringContaining(join('/packages/projectB')));
).toEqual(expect.stringContaining(joinPathFragments('/packages/projectB')));
});

it('should work for a yarn classic style link reference', async () => {
Expand All @@ -78,6 +78,6 @@ describe('resolveVersionSpec()', () => {
'link:../projectB',
'/packages/projectB'
)
).toEqual(expect.stringContaining(join('/packages/projectB')));
).toEqual(expect.stringContaining(joinPathFragments('/packages/projectB')));
});
});
6 changes: 3 additions & 3 deletions packages/js/src/generators/sync/sync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
readJson,
readNxJson,
writeJson,
normalizePath,
} from '@nx/devkit';
import { relative } from 'node:path';
import { PLUGIN_NAME, TscPluginOptions } from '../../plugins/typescript/plugin';
Expand Down Expand Up @@ -103,9 +104,8 @@ export async function syncGenerator(tree: Tree, options: SyncSchema) {
sourceTsconfig.references = sourceTsconfig.references || [];

// Ensure the project reference for the target is set
const relativePathToTargetRoot = relative(
sourceProjectNode.data.root,
targetProjectNode.data.root
const relativePathToTargetRoot = normalizePath(
relative(sourceProjectNode.data.root, targetProjectNode.data.root)
);
if (
!sourceTsconfig.references.some(
Expand Down

0 comments on commit fb462fa

Please sign in to comment.