-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils.js
68 lines (55 loc) · 1.54 KB
/
utils.js
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
const { packageJson } = require('mrm-core');
function capitalizeFirstLetter(string) {
return string.charAt(0).toUpperCase() + string.slice(1);
}
const removeMatch = (lines, match) => {
return lines.filter((value) => !value.match(match));
};
const cosmiconfig = (name) => {
const rcName = `.${name.replace('-', '')}rc`;
const configs = [
`${rcName}`,
`${rcName}.json`,
`${rcName}.json5`,
`${rcName}.yaml`,
`${rcName}.yml`,
`${rcName}.js`,
`${rcName}.cjs`,
`${rcName}.mjs`,
`${rcName}.ts`,
`${name}.config.js`,
`${name}.config.cjs`,
`${name}.config.mjs`,
`${name}.config.ts`,
];
return configs;
};
const prettierConfig = () => ({
set: (obj) => {
return packageJson().set('prettier', obj);
},
merge: (obj) => {
return packageJson().merge({ prettier: obj });
},
save: packageJson().save,
});
const hasHusky = () => !!packageJson().get('devDependencies.husky');
const hasEslint = () => !!packageJson().get('devDependencies.eslint');
const hasPrettier = () => !!packageJson().get('devDependencies.prettier');
const hasTypescript = () => !!packageJson().get('devDependencies.typescript');
const hasLintStaged = () => !!packageJson().get('devDependencies.lint-staged');
const hasReact = () => !!packageJson().get('dependencies.react');
const hasVue = () => !!packageJson().get('dependencies.vue');
module.exports = {
capitalizeFirstLetter,
removeMatch,
cosmiconfig,
prettierConfig,
hasHusky,
hasEslint,
hasPrettier,
hasTypescript,
hasLintStaged,
hasReact,
hasVue,
};