-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add interactive command support
- Loading branch information
Showing
3 changed files
with
37 additions
and
11 deletions.
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
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 |
---|---|---|
@@ -1,12 +1,36 @@ | ||
const fs = require('fs'); | ||
const legilimens = require('./legilimens.js'); | ||
const inquirer = require('inquirer'); | ||
|
||
const config = JSON.parse(fs.readFileSync('.config.json','utf8')); | ||
if (fs.existsSync(".config.json")) { | ||
const config = JSON.parse(fs.readFileSync('.config.json','utf8')); | ||
const token = config.token; | ||
const repoPath = config.repo_path; | ||
const baseBranch = process.argv[2] || config.repo_branch || 'master'; | ||
legilimens(token, repoPath, baseBranch, (output) => { | ||
console.log(output); | ||
}) | ||
} else { | ||
const questions = [{ | ||
type: "input", | ||
name: "repo", | ||
message: "what is your repo path? (as hubotio/hubot in https://github.com/hubotio/hubot)\n" | ||
}, { | ||
type: "input", | ||
name: "branch", | ||
message: "what is your repo release branch?\n", | ||
default: "master" | ||
}, { | ||
type: "input", | ||
name: "branch", | ||
message: "give me a access token for API, you can get one via https://github.com/settings/tokens\n(optional, not need for public repo)", | ||
default: null | ||
}] | ||
inquirer.prompt(questions).then(function (answers) { | ||
legilimens(answers.token, answers.repo, answers.branch, (output) => { | ||
console.log(output); | ||
}) | ||
}); | ||
} | ||
|
||
const token = config.token; | ||
const repoPath = config.repo_path; | ||
const baseBranch = process.argv[2] || config.repo_branch || 'master'; | ||
|
||
legilimens(token, repoPath, baseBranch, (output) => { | ||
console.log(output); | ||
}) |
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