diff --git a/server/src/utilities/extractSourceFiles.test.ts b/server/src/utilities/extractSourceFiles.test.ts index a581ad9..cf45204 100644 --- a/server/src/utilities/extractSourceFiles.test.ts +++ b/server/src/utilities/extractSourceFiles.test.ts @@ -1,4 +1,6 @@ const globby = require('globby'); +import { join } from 'path'; + import extractSourceFiles from './extractSourceFiles'; describe('extractSourceFiles.ts', () => { @@ -12,16 +14,16 @@ describe('extractSourceFiles.ts', () => { it('should not error out', () => { extractSourceFiles('test'); - expect(globby.sync).toHaveBeenLastCalledWith([ `test\\**\\*.+(js|jsx|ts|tsx)`, '!**\\node_modules' ]); + expect(globby.sync).toHaveBeenLastCalledWith([ join('test', '**', '*.+(js|jsx|ts|tsx)'), join('!**', 'node_modules') ]); }); it('should handle a Windows style path', () => { extractSourceFiles('file:///c:/some/windows/style/path'); - expect(globby.sync).toHaveBeenLastCalledWith([ `\\some\\windows\\style\\path\\**\\*.+(js|jsx|ts|tsx)`, '!**\\node_modules' ]); + expect(globby.sync).toHaveBeenLastCalledWith([ join('/', 'some', 'windows', 'style', 'path', '**', '*.+(js|jsx|ts|tsx)'), join('!**', 'node_modules') ]); }); it('should handle a Windows style path with an escaped colon', () => { extractSourceFiles('file:///c%3A/some/windows/style/path'); - expect(globby.sync).toHaveBeenLastCalledWith([ `\\some\\windows\\style\\path\\**\\*.+(js|jsx|ts|tsx)`, '!**\\node_modules' ]); + expect(globby.sync).toHaveBeenLastCalledWith([ join('/', 'some', 'windows', 'style', 'path', '**', '*.+(js|jsx|ts|tsx)'), join('!**', 'node_modules') ]); }); }); diff --git a/server/src/utilities/extractSourceFiles.ts b/server/src/utilities/extractSourceFiles.ts index 72643ee..6469483 100644 --- a/server/src/utilities/extractSourceFiles.ts +++ b/server/src/utilities/extractSourceFiles.ts @@ -1,5 +1,5 @@ import { sync } from 'globby'; -import { join, normalize } from 'path'; +import { join } from 'path'; function extractSourceFiles (rootDirectory: string): string[] { let normalized = rootDirectory; @@ -15,7 +15,7 @@ function extractSourceFiles (rootDirectory: string): string[] { normalized = normalized.substring(escapedColonIndex + 3); } - const files = sync([ join(normalize(normalized), '**', '*.+(js|jsx|ts|tsx)'), join('!**', 'node_modules') ]); + const files = sync([ join(normalized, '**', '*.+(js|jsx|ts|tsx)'), join('!**', 'node_modules') ]); return files; }