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 14, 2024
1 parent 54f52bb commit 91ad3f0
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 11 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
4 changes: 2 additions & 2 deletions packages/js/src/generators/release-version/release-version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}.
Expand Down Expand Up @@ -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'
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { join } from 'path';
import { resolveVersionSpec } from './resolve-version-spec';

describe('resolveVersionSpec()', () => {
Expand Down Expand Up @@ -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 () => {
Expand All @@ -78,6 +77,6 @@ describe('resolveVersionSpec()', () => {
'link:../projectB',
'/packages/projectB'
)
).toEqual(expect.stringContaining(join('/packages/projectB')));
).toEqual(expect.stringContaining('/packages/projectB'));
});
});

0 comments on commit 91ad3f0

Please sign in to comment.