-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsettings.ts
45 lines (40 loc) · 1.26 KB
/
settings.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
export const defaultTemplateDirectory: string = '_templates/components';
export const defaultComponentDirectory: string = 'src/components';
export function getFileGlobs( directory: string = '.' ): Array<string> {
return [
`${directory}/**/*.js`,
`${directory}/**/*.json`,
`${directory}/**/*.jsx`,
`${directory}/**/*.ts`,
`${directory}/**/*.tsx`,
`${directory}/**/*.css`,
`${directory}/**/*.scss`,
`${directory}/**/*.sass`,
`${directory}/**/*.less`,
`${directory}/**/*.styl`,
`${directory}/**/*.graphql`,
`${directory}/**/*.gql`,
];
}
export function getConfig( verbose: boolean = false ) {
const defaultConfig = {
"templateDirectory": defaultTemplateDirectory,
"componentDirectory": defaultComponentDirectory,
};
let userConfig = {};
try {
userConfig = require( `${process.cwd()}/.component-cli.js` ).config;
if ( verbose ) {
console.log( `Project-level config found @ ${process.cwd()}/.component-cli.js:` );
console.log( `${JSON.stringify( userConfig, null, 2 )}\n` );
}
} catch ( missingConfigError ) {
if ( verbose ) {
console.log( `Project-level config not found @ ${process.cwd()}/.component-cli.js.\n` );
}
}
return {
...defaultConfig,
...userConfig,
};
}