Skip to content

Commit

Permalink
feat: 查看git当前配置用户名邮箱
Browse files Browse the repository at this point in the history
  • Loading branch information
StreakingMan committed Feb 22, 2022
1 parent 8a43293 commit b0e3f42
Show file tree
Hide file tree
Showing 5 changed files with 275 additions and 7 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
## StreakingMan Cli

### 查看git当前配置名称和邮箱
```
skm check git
```
9 changes: 9 additions & 0 deletions actions/check-git.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const {execSync} = require('child_process')
export const checkGit = (propName) => {
if (!propName || propName === 'username') {
console.log(`git config user.name ${execSync('git config user.name')}`)
}
if (!propName || propName === 'email') {
console.log(`git config user.email ${execSync('git config user.email')}`)
}
}
22 changes: 21 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,22 @@
const { program } = require('commander');
#!/usr/bin/env node
import {checkGit} from "./actions/check-git";

const {program} = require('commander');
const fs = require('fs')
const path = require('path')
const {version} = JSON.parse(fs.readFileSync(path.join(__dirname, '../package.json')).toString())

const CLINAME = 'skm'

program.version(`${CLINAME}@${version}`, '-v')
.helpOption('-h', '帮助信息')
.usage('<command> [options]')
.name(CLINAME)

program.command('check git <propName>')
.description('查看当前git配置用户名和邮箱')
.action(checkGit)

program.showHelpAfterError(`${CLINAME} -h 查看帮助`)
program.addHelpCommand(false)
program.parse(process.argv)
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "1.0.0",
"description": "常用命令行",
"main": "index.js",
"bin": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"release": "standard-version"
Expand All @@ -13,6 +14,7 @@
"commander": "^9.0.0"
},
"devDependencies": {
"inquirer": "^8.2.0",
"standard-version": "^9.3.2"
}
}
Loading

0 comments on commit b0e3f42

Please sign in to comment.