File tree Expand file tree Collapse file tree 5 files changed +27
-3
lines changed
bazel/integration/test_runner Expand file tree Collapse file tree 5 files changed +27
-3
lines changed Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ ts_library(
1414 "@npm//@types/node" ,
1515 "@npm//@types/tmp" ,
1616 "@npm//tmp" ,
17+ "@npm//true-case-path" ,
1718 ],
1819)
1920
Original file line number Diff line number Diff line change 77 */
88
99import * as fs from 'fs' ;
10+ import { trueCasePath } from 'true-case-path' ;
1011
1112/** Gets whether the file is executable or not. */
1213export async function isExecutable ( filePath : string ) : Promise < boolean > {
@@ -18,6 +19,16 @@ export async function isExecutable(filePath: string): Promise<boolean> {
1819 }
1920}
2021
22+ /**
23+ * Gets a case-exact system realpath for the specified path.
24+ *
25+ * This is useful for example because Bazel passes `C:\users\<..>` as action input, but
26+ * the actual case-exact path for the current platform would be: `C:\Users\<..>`.
27+ */
28+ export async function getCaseExactRealpath ( filePath : string ) : Promise < string > {
29+ return trueCasePath ( filePath ) ;
30+ }
31+
2132/** Adds the `write` permission to the given file using `chmod`. */
2233export async function addWritePermissionFlag ( filePath : string ) {
2334 if ( await isExecutable ( filePath ) ) {
Original file line number Diff line number Diff line change 99import * as childProcess from 'child_process' ;
1010import * as path from 'path' ;
1111import { debug } from './debug' ;
12+ import { getCaseExactRealpath } from './file_system_utils' ;
1213
1314/**
1415 * Regular expression matching environment variable substitutions
@@ -41,21 +42,26 @@ export function expandEnvironmentVariableSubstitutions(
4142 * @returns a Promise that resolves with a boolean indicating whether the
4243 * command completed successfully or not.
4344 */
44- export function runCommandInChildProcess (
45+ export async function runCommandInChildProcess (
4546 binary : string ,
4647 args : string [ ] ,
4748 workingDir : string ,
4849 env : NodeJS . ProcessEnv ,
4950) : Promise < boolean > {
5051 const humanReadableCommand = `${ binary } ${ args . length ? ` ${ args . join ( ' ' ) } ` : '' } ` ;
52+ // Note: We resolve the working directory to a case-exact system `realpath`. This is
53+ // necessary as otherwise Node module resolution could behave unexpectedly when invoked
54+ // tools down-the-line resolve files with an actual system realpath. Here is an example
55+ // within Microsoft's `playwright`: https://github.com/microsoft/playwright/issues/9193.
56+ const normalizedWorkingDir = await getCaseExactRealpath ( path . posix . normalize ( workingDir ) ) ;
5157
52- debug ( `Executing command: ${ humanReadableCommand } in ${ workingDir } ` ) ;
58+ debug ( `Executing command: ${ humanReadableCommand } in ${ normalizedWorkingDir } ` ) ;
5359
5460 return new Promise < boolean > ( ( resolve ) => {
5561 const commandProcess = childProcess . spawn ( binary , args , {
5662 shell : true ,
5763 stdio : 'inherit' ,
58- cwd : workingDir ,
64+ cwd : normalizedWorkingDir ,
5965 env,
6066 } ) ;
6167
Original file line number Diff line number Diff line change 5656 "selenium-webdriver" : " 3.5.0" ,
5757 "semver" : " ^7.3.5" ,
5858 "tmp" : " ^0.2.1" ,
59+ "true-case-path" : " ^2.2.1" ,
5960 "ts-node" : " ^10.2.1" ,
6061 "tslib" : " ^2.3.0" ,
6162 "tslint" : " ^6.1.3" ,
Original file line number Diff line number Diff line change @@ -3091,6 +3091,11 @@ trim-newlines@^3.0.0:
30913091 resolved "https://registry.yarnpkg.com/trim-newlines/-/trim-newlines-3.0.1.tgz#260a5d962d8b752425b32f3a7db0dcacd176c144"
30923092 integrity sha512-c1PTsA3tYrIsLGkJkzHF+w9F2EyxfXGo4UyJc4pFL++FMjnq0HJS69T3M7d//gKrFKwy429bouPescbjecU+Zw==
30933093
3094+ " true-case-path@^2.2.1 " :
3095+ version "2.2.1"
3096+ resolved "https://registry.yarnpkg.com/true-case-path/-/true-case-path-2.2.1.tgz#c5bf04a5bbec3fd118be4084461b3a27c4d796bf"
3097+ integrity sha512-0z3j8R7MCjy10kc/g+qg7Ln3alJTodw9aDuVWZa3uiWqfuBMKeAeP2ocWcxoyM3D73yz3Jt/Pu4qPr4wHSdB/Q==
3098+
30943099ts-node@^10.2.1 :
30953100 version "10.4.0"
30963101 resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-10.4.0.tgz#680f88945885f4e6cf450e7f0d6223dd404895f7"
You can’t perform that action at this time.
0 commit comments