-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Pull validation methods into own file. Fix version check.
- Loading branch information
Sean O'Donohue
committed
Feb 26, 2018
1 parent
48bfe7a
commit 0d738b7
Showing
2 changed files
with
23 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,40 @@ | ||
#!/usr/bin/env node | ||
|
||
const ax = require('axolemma') | ||
const cli = require('commander') | ||
const inquirer = require('inquirer') | ||
const semver = require('semver') | ||
const {Subject} = require('rxjs') | ||
const {bold, green, blue, red} = require('chalk') | ||
|
||
const {version} = require('../package.json') | ||
|
||
if (semver.lt('8.0.0')) { | ||
console.log(red(`Axolemma supports Node version ${bold('8')} or higher.`)) | ||
if (semver.lt(process.version,'8.0.0')) { | ||
console.log(red(`Axolemma supports Node ${bold('v8.0.0')} or higher.`)) | ||
console.log(red(`You are currently using ${bold(process.version)}.`)) | ||
return process.exit(1) | ||
} | ||
|
||
const {version} = require('../package.json') | ||
|
||
const ax = require('../') | ||
const {isAlphanumeric} = require('./validation') | ||
|
||
|
||
|
||
cli.version('0.1.0') | ||
cli.on('--help', () => { | ||
console.log(blue(`Type ${bold(green('axolemma'))} to start creating.`)) | ||
}) | ||
|
||
const prompts = new Subject() | ||
inquirer.prompt(prompts) | ||
inquirer.prompt(prompts).ui.process.subscribe(console.log, console.log, function(answers){ | ||
console.log(answers) | ||
ax.generate(answers) // Eventually this will be done during the prompts, and user will be prompted to approve of the generated map. | ||
}) | ||
|
||
prompts.next({ | ||
type: 'input', | ||
name: 'areaTitle', | ||
message: blue('What would you like to title this area?'), | ||
validate(input) { | ||
const alphanumeric = /^[0-9a-zA-Z]+$/ | ||
return input.match(alphanumeric) | ||
} | ||
validate: isAlphanumeric, | ||
}) | ||
|
||
prompts.complete() |
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,6 @@ | ||
module.exports = { | ||
isAlphanumeric(input) { | ||
const alphanumeric = /^[0-9a-zA-Z]+$/ | ||
return input.match(alphanumeric) | ||
} | ||
} |