File tree Expand file tree Collapse file tree 3 files changed +47
-5
lines changed Expand file tree Collapse file tree 3 files changed +47
-5
lines changed Original file line number Diff line number Diff line change 1+ import { realpathSync } from 'fs'
2+
3+ export const getCaseSensitiveCwd = ( path : string ) : string => {
4+ try {
5+ const cwd = realpathSync . native ( path )
6+ if ( cwd ) {
7+ return cwd
8+ }
9+ } catch { }
10+ return path
11+ }
Original file line number Diff line number Diff line change 11import { dirname } from 'path'
22import { Args } from './constants'
3+ import { getCaseSensitiveCwd } from './cwd'
34import { getProcessEnv } from '../env'
45import { joinEnvPath } from '../util/env'
56
@@ -45,13 +46,11 @@ export const getOptions = (
4546) : ExecutionDetails => {
4647 const executable = getExecutable ( pythonBinPath , cliPath )
4748 const args = getArgs ( pythonBinPath , cliPath , ...originalArgs )
48- const command = [ executable , ...args ] . join ( ' ' )
49- const env = getEnv ( pythonBinPath )
5049 return {
5150 args,
52- command,
53- cwd,
54- env,
51+ command : [ executable , ... args ] . join ( ' ' ) ,
52+ cwd : getCaseSensitiveCwd ( cwd ) ,
53+ env : getEnv ( pythonBinPath ) ,
5554 executable
5655 }
5756}
Original file line number Diff line number Diff line change 1+ import { sep } from 'path'
2+ import { describe , it , suite } from 'mocha'
3+ import { expect } from 'chai'
4+ import { dvcDemoPath } from '../../util'
5+ import { getCaseSensitiveCwd } from '../../../cli/cwd'
6+
7+ suite ( 'Cwd Test Suite' , ( ) => {
8+ describe ( 'getCaseSensitiveCwd' , ( ) => {
9+ it ( 'should return a case sensitive path for case sensitive systems which matches os.getcwd() in the CLI' , ( ) => {
10+ const caseInsensitiveCwd = dvcDemoPath . toUpperCase ( )
11+ const realpathCwd = getCaseSensitiveCwd ( caseInsensitiveCwd )
12+
13+ expect ( realpathCwd ) . to . have . length ( dvcDemoPath . length )
14+ expect ( realpathCwd ) . not . to . equal (
15+ [ 'win32' , 'darwin' ] . includes ( process . platform )
16+ ? caseInsensitiveCwd
17+ : caseInsensitiveCwd . toLowerCase ( ) ,
18+ 'should behave differently on different systems'
19+ )
20+
21+ const caseInsensitiveArray = caseInsensitiveCwd . split ( sep )
22+ const realPathArray = realpathCwd . split ( sep )
23+
24+ expect ( caseInsensitiveArray ) . to . have . length ( realPathArray . length )
25+ for ( let i = 0 ; i <= caseInsensitiveArray . length ; i ++ ) {
26+ expect ( caseInsensitiveArray [ i ] ) . to . match (
27+ new RegExp ( realPathArray [ i ] , 'i' )
28+ )
29+ }
30+ } )
31+ } )
32+ } )
You can’t perform that action at this time.
0 commit comments