Skip to content

Commit

Permalink
feat: 🎸 support multiple sources
Browse files Browse the repository at this point in the history
  • Loading branch information
shaharkazaz committed Oct 10, 2020
1 parent 03e25a4 commit 5e16de2
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 15 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,12 @@ npx import-conductor -s customer.component.ts -p @myorg

## Options

- `source` - Regex to that matches the source files: (defaults to `./src/**/*.ts`)
- `source` - Regex to that matches the source files: (defaults to `[./src/**/*.ts]`)

```shell script
import-conductor --source 'mySrc/**/*.ts'
import-conductor -s 'mySrc/**/*.ts'
import-conductor 'mySrc/**/*.ts'
import-conductor --source mySrc/**/*.ts anotherSrc/**/*.ts
import-conductor -s mySrc/**/*.ts anotherSrc/**/*.ts
import-conductor mySrc/**/*.ts anotherSrc/**/*.ts
```

- `ignore`\* - Ignore files that match the pattern: (defaults to `[]`)
Expand Down
10 changes: 3 additions & 7 deletions __tests__/optimize-imports.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,15 @@ import * as config from '@ic/config';
import fs from 'fs';
import { Config } from '@ic/types';
import { readmeExample, comments, testCase } from './optimize-imports-mocks';
import { defaultConfig } from '@ic/defaultConfig';

jest.mock('fs');

describe('optimizeImports', () => {
const basicConfig: Config = {
ignore: [],
dryRun: false,
verbose: false,
staged: false,
source: 'test.ts',
...defaultConfig,
source: ['test.ts'],
userLibPrefixes: ['@myorg'],
autoAdd: false,
autoMerge: true,
thirdPartyDependencies: new Set<string>(['@angular/core', 'rxjs']),
};

Expand Down
1 change: 1 addition & 0 deletions src/cliOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export const optionDefinitions = [
name: 'source',
alias: 's',
type: String,
multiple: true,
defaultOptions: true,
description: 'Path to the source files',
},
Expand Down
4 changes: 2 additions & 2 deletions src/conductor/get-files-paths.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { sync } from 'glob';

export function getFilesPaths(pattern: string): string[] {
return sync(pattern, { nodir: true });
export function getFilesPaths(source: string[]): string[] {
return source.map((pattern) => sync(pattern, { nodir: true })).flat();
}
2 changes: 1 addition & 1 deletion src/defaultConfig.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Config } from './types';

export const defaultConfig: Config = {
source: './src/**/*.ts',
source: ['./src/**/*.ts'],
userLibPrefixes: [],
autoMerge: true,
autoAdd: false,
Expand Down
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export interface Config {
staged: boolean;
autoAdd: boolean;
autoMerge: boolean;
source: string;
source: string[];
ignore: string[];
userLibPrefixes: string[];
thirdPartyDependencies?: Set<string>;
Expand Down

0 comments on commit 5e16de2

Please sign in to comment.