1- import path , { normalize } from 'node:path'
1+ import { sep } from 'node:path'
22import { run } from 'jscodeshift/src/Runner'
33import prompts from 'prompts'
44import { transform } from '../transform'
@@ -8,10 +8,7 @@ const defaultOptions = {
88 silent : true ,
99}
1010
11- const { platform } = process
12- const locale = path [ platform === 'win32' ? 'win32' : 'posix' ]
13-
14- const transformerPath = ( inputPath : string ) => locale . normalize ( inputPath )
11+ const getSystemPath = ( inputPath : string ) => inputPath . replaceAll ( '/' , sep )
1512
1613jest . mock ( 'jscodeshift/src/Runner' , ( ) => ( {
1714 run : jest . fn ( ) ,
@@ -33,8 +30,8 @@ describe('interactive mode', () => {
3330 expect ( spyOnConsole ) . not . toHaveBeenCalled ( )
3431 expect ( run ) . toHaveBeenCalledTimes ( 1 )
3532 expect ( run ) . toHaveBeenCalledWith (
36- expect . stringContaining ( '/transforms/magic-redirect.js' ) ,
37- expect . arrayContaining ( [ expect . stringContaining ( transformerPath ( '/transforms/__testfixtures__' ) ) ] ) ,
33+ expect . stringContaining ( getSystemPath ( '/transforms/magic-redirect.js' ) ) ,
34+ expect . arrayContaining ( [ expect . stringContaining ( getSystemPath ( '/transforms/__testfixtures__' ) ) ] ) ,
3835 {
3936 babel : false ,
4037 dry : true ,
@@ -56,8 +53,8 @@ describe('interactive mode', () => {
5653 expect ( spyOnConsole ) . not . toHaveBeenCalled ( )
5754 expect ( run ) . toHaveBeenCalledTimes ( 1 )
5855 expect ( run ) . toHaveBeenCalledWith (
59- expect . stringContaining ( '/transforms/magic-redirect.js' ) ,
60- expect . arrayContaining ( [ expect . stringContaining ( transformerPath ( '/transforms/__testfixtures__' ) ) ] ) ,
56+ expect . stringContaining ( getSystemPath ( '/transforms/magic-redirect.js' ) ) ,
57+ expect . arrayContaining ( [ expect . stringContaining ( getSystemPath ( '/transforms/__testfixtures__' ) ) ] ) ,
6158 {
6259 babel : false ,
6360 dry : true ,
@@ -79,8 +76,8 @@ describe('interactive mode', () => {
7976 expect ( spyOnConsole ) . not . toHaveBeenCalled ( )
8077 expect ( run ) . toHaveBeenCalledTimes ( 1 )
8178 expect ( run ) . toHaveBeenCalledWith (
82- expect . stringContaining ( '/transforms/magic-redirect.js' ) ,
83- expect . arrayContaining ( [ expect . stringContaining ( transformerPath ( '__testfixtures__' ) ) ] ) ,
79+ expect . stringContaining ( getSystemPath ( '/transforms/magic-redirect.js' ) ) ,
80+ expect . arrayContaining ( [ expect . stringContaining ( '__testfixtures__' ) ] ) ,
8481 {
8582 babel : false ,
8683 dry : true ,
@@ -106,7 +103,7 @@ describe('Non-Interactive Mode', () => {
106103 expect ( spyOnConsole ) . not . toHaveBeenCalled ( )
107104 expect ( run ) . toHaveBeenCalledTimes ( 1 )
108105 expect ( run ) . toHaveBeenCalledWith (
109- expect . stringContaining ( '/transforms/magic-redirect.js' ) ,
106+ expect . stringContaining ( getSystemPath ( '/transforms/magic-redirect.js' ) ) ,
110107 expect . arrayContaining ( [ expect . stringContaining ( '__testfixtures__' ) ] ) ,
111108 {
112109 babel : false ,
0 commit comments