-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
579c0a7
commit af87343
Showing
3 changed files
with
57 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#!/usr/bin/env node | ||
|
||
const yParser = require('yargs-parser'); | ||
const semver = require('semver'); | ||
const { existsSync } = require('fs'); | ||
const { join } = require('path'); | ||
const chalk = require('chalk'); | ||
|
||
// print version and @local | ||
const args = yParser(process.argv.slice(2)); | ||
|
||
if (args.v || args.version) { | ||
// eslint-disable-next-line global-require | ||
console.log(require('./package').version); | ||
if (existsSync(join(__dirname, '.local'))) { | ||
console.log(chalk.cyan('@local')); | ||
} | ||
process.exit(0); | ||
} | ||
|
||
if (!semver.satisfies(process.version, '>= 8.0.0')) { | ||
console.error(chalk.red('✘ The generator will only work with Node v8.0.0 and up!')); | ||
process.exit(1); | ||
} | ||
const cwd = process.cwd(); | ||
|
||
const option = args._[0]; | ||
|
||
switch (option) { | ||
case 'verify-commit': | ||
// eslint-disable-next-line global-require | ||
require('./dist/verifyCommit')({ cwd, ...args }); | ||
break; | ||
|
||
default: | ||
if (args.h || args.help) { | ||
const details = ` | ||
Commands: | ||
${chalk.cyan('verify-commit')} 检查 commit 提交的信息 | ||
Examples: | ||
${chalk.gray('fabric')} | ||
pro -h | ||
${chalk.gray('verify-commit ')} | ||
pro verify-commit | ||
`.trim(); | ||
console.log(details); | ||
} | ||
break; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,3 +45,5 @@ if (!commitRE.test(msg)) { | |
process.exit(1); | ||
}); | ||
} | ||
|
||
export default () => {}; |