Skip to content

Commit

Permalink
fix(node): directory separators are inconsistent between platforms in…
Browse files Browse the repository at this point in the history
… tasks.json and package.json (#3387)

Related to #3284 (comment) 

## Changelog

1. Use POSIX path for tasks with lambda entrypoint.

![Screenshot 2024-02-23 162624](https://github.com/projen/projen/assets/22875166/5bf19a20-b360-4b66-a4cf-7c264deb810d)

2. Normalize `NodeProject.artifactsJavascriptDirectory`, resulting in `dist\\js` being written on Windows instead of `dist/js`.

![Screenshot 2024-02-23 162616](https://github.com/projen/projen/assets/22875166/951670b7-a83e-4631-91c3-58028522f9dc)




---
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
  • Loading branch information
gmeligio committed Feb 24, 2024
1 parent a5f5672 commit 2aa861d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
12 changes: 9 additions & 3 deletions src/javascript/node-project.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { join, relative } from "path";
import { relative, posix } from "path";
import { Bundler, BundlerOptions } from "./bundler";
import { Jest, JestOptions } from "./jest";
import { LicenseChecker, LicenseCheckerOptions } from "./license-checker";
Expand Down Expand Up @@ -49,7 +49,7 @@ import {
} from "../release";
import { filteredRunsOnOptions } from "../runner-options";
import { Task } from "../task";
import { deepMerge } from "../util";
import { deepMerge, normalizePersistedPath } from "../util";
import { ensureRelativePathStartsWithDot } from "../util/path";
import { Version } from "../version";

Expand Down Expand Up @@ -486,7 +486,13 @@ export class NodeProject extends GitHubProject {
options.workflowGitIdentity ?? DEFAULT_GITHUB_ACTIONS_USER;
this.workflowPackageCache = options.workflowPackageCache ?? false;
this.artifactsDirectory = options.artifactsDirectory ?? "dist";
this.artifactsJavascriptDirectory = join(this.artifactsDirectory, "js");
const normalizedArtifactsDirectory = normalizePersistedPath(
this.artifactsDirectory
);
this.artifactsJavascriptDirectory = posix.join(
normalizedArtifactsDirectory,
"js"
);

this.runScriptCommand = (() => {
switch (this.packageManager) {
Expand Down
4 changes: 2 additions & 2 deletions src/javascript/util.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { existsSync, readFileSync } from "fs";
import { basename, dirname, extname, join, sep, resolve } from "path";
import { basename, dirname, extname, join, sep, resolve, posix } from "path";
import * as semver from "semver";
import { NodePackage } from "./node-package";
import { Project } from "../project";
Expand Down Expand Up @@ -30,7 +30,7 @@ export function renderBundleName(entrypoint: string) {
const p = parts.join(sep);
const dir = dirname(p);
const base = basename(p, extname(p));
return join(dir, base);
return posix.join(dir, base);
}

/**
Expand Down

0 comments on commit 2aa861d

Please sign in to comment.