Skip to content

Commit 5f6590c

Browse files
bearyanbearyan
authored andcommitted
feat: 新增指定配置文件的能力
1 parent eeef0e2 commit 5f6590c

File tree

4 files changed

+38
-2
lines changed

4 files changed

+38
-2
lines changed

.picklogrc.devops.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
module.exports = {
2+
filters: [
3+
{
4+
name: 'Changes',
5+
regExp: /[\u4e00-\u9fa5]/,
6+
}
7+
],
8+
parse(commits){
9+
let output = '';
10+
11+
commits.forEach((log) => {
12+
log.results.forEach((result) => {
13+
output += `${result.filter.name}:\n`;
14+
15+
result.commits.forEach((commit) => {
16+
output += `- ${commit.s} ${commit.an}\n`;
17+
});
18+
});
19+
});
20+
21+
return output;
22+
}
23+
};

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,12 @@ $ picklog -o CHANGELOG.md
4949

5050
e.g: `picklog -g v2.0.0 -w CHANGELOG.md`
5151

52+
- **`-c` or `--config`**
53+
54+
指定配置文件,默认是`.picklogrc.js` ( Custom config file. Default ".picklogrc" )
55+
56+
e.g: `picklog -c .picklogrc.dev.js`
57+
5258

5359
### API
5460
```javascript

bin/picklog.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ const { argv } = yargs
4242
.option('o', {
4343
alias: 'overwrite',
4444
describe: 'Overwrite stdout to this file.',
45+
})
46+
.option('c', {
47+
alias: 'config',
48+
describe: 'Custom config file. (Default ".picklogrc")',
4549
});
4650

4751
if (argv._.indexOf('init') > -1) {

index.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,15 @@ function picklog(_args) {
88
gitLogArgs: '', // 透传给命令 git log 的参数
99
latest: false, // 是否只取上一个tag后的commit
1010
}, _args);
11+
12+
const picklogrc = args.config || '.picklogrc.js';
13+
1114
let setting;
1215
let pkg;
1316

1417
try {
15-
fs.accessSync(path.resolve('.picklogrc.js'));
16-
setting = require(path.resolve('.picklogrc.js')); // eslint-disable-line global-require,import/no-dynamic-require
18+
fs.accessSync(path.resolve(picklogrc));
19+
setting = require(path.resolve(picklogrc)); // eslint-disable-line global-require,import/no-dynamic-require
1720

1821
fs.accessSync(path.resolve('package.json'));
1922
pkg = require(path.resolve('package.json')); // eslint-disable-line global-require,import/no-dynamic-require

0 commit comments

Comments
 (0)