Skip to content

Commit 56173b7

Browse files
authored
Merge pull request #2 from serrg/feat-config-arg
feat: config arg
2 parents 053e62e + 30b8894 commit 56173b7

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
@@ -27,6 +27,11 @@ const outputDir = outDirArg
2727
? path.resolve('./', outDirArg)
2828
: path.resolve(nodeModules, '@types/__federated_types/');
2929

30+
const configPathArg = getArg('--config');
31+
const configPath = configPathArg
32+
? path.resolve(configPathArg)
33+
: null;
34+
3035
const findFederationConfig = (base) => {
3136
let files = fs.readdirSync(base);
3237
let queue = [];
@@ -46,7 +51,13 @@ const findFederationConfig = (base) => {
4651
}
4752
};
4853

49-
const federationConfigPath = findFederationConfig('./');
54+
if (configPath && !fs.existsSync(configPath)) {
55+
console.error(`ERROR: Unable to find a provided config: ${configPath}`);
56+
process.exit(1);
57+
}
58+
59+
const federationConfigPath = configPath || findFederationConfig('./');
60+
5061

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

0 commit comments

Comments
 (0)