Merge pull request #28 from kawwong/extract-source-files-test
Fix extractSourceFiles tests to work cross platform
This commit is contained in:
Коммит
d529c3d668
|
@ -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') ]);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче