Skip to content

Commit 17f303c

Browse files
authored
feat: use custom config path with --config arg (#10)
* feat: use custom config path with `--config` arg * Added README
1 parent 1660999 commit 17f303c

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,13 @@ scripts: {
7373
"make-types": "make-federated-types --outputDir ../../my_types/"
7474
}
7575
```
76+
77+
#### `package.json`
78+
79+
If you would like to specify custom path to the config, you can pass `--config` parameter like so:
80+
81+
```json
82+
scripts: {
83+
"make-types": "make-federated-types --config ./path/to/my/config.json --outputDir ../../my_types/"
84+
}
85+
```

cli.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ const outputDir = outDirArg
1515
? path.resolve('./', outDirArg)
1616
: path.resolve(__dirname, '../../@types/__federated_types/');
1717

18+
const configPathArg = getArg('--config');
19+
const configPath = configPathArg
20+
? path.resolve(configPathArg)
21+
: null;
22+
1823
const findFederationConfig = (base) => {
1924
let files = fs.readdirSync(base);
2025
let queue = [];
@@ -34,7 +39,13 @@ const findFederationConfig = (base) => {
3439
}
3540
};
3641

37-
const federationConfigPath = findFederationConfig('./');
42+
if (configPath && !fs.existsSync(configPath)) {
43+
console.error(`ERROR: Unable to find a provided config: ${configPath}`);
44+
process.exit(1);
45+
}
46+
47+
const federationConfigPath = configPath || findFederationConfig('./');
48+
3849

3950
if (federationConfigPath === undefined) {
4051
console.error(`ERROR: Unable to find a federation.config.json file in this package`);

0 commit comments

Comments
 (0)