mirror of https://github.com/codefeathers/mark
Muthu Kumar
7 years ago
2 changed files with 57 additions and 0 deletions
@ -0,0 +1,22 @@ |
|||||
|
const CMDjs = require('@codefeathers/cmd-js/index'); |
||||
|
const installer = require('./lib/installer'); |
||||
|
const { help, login, logout, commit } = require('./lib/commands.js'); |
||||
|
|
||||
|
const mark = input => { |
||||
|
const args = input.args; |
||||
|
if (args && args.length === 0) { |
||||
|
help(); |
||||
|
} |
||||
|
|
||||
|
const cmd = new CMDjs( |
||||
|
args, |
||||
|
) |
||||
|
|
||||
|
cmd |
||||
|
.use( ['-h', '--help'], help ) |
||||
|
.use( 'login', login ) |
||||
|
.use( 'logout', logout ) |
||||
|
|
||||
|
} |
||||
|
|
||||
|
module.exports = mark; |
@ -0,0 +1,35 @@ |
|||||
|
// Native
|
||||
|
const fs = require('fs'); |
||||
|
const { promisify } = require('util'); |
||||
|
|
||||
|
const open = promisify(fs.open); |
||||
|
const write = promisify(fs.writeFile); |
||||
|
|
||||
|
// Modules
|
||||
|
const readline = require('readline-promise').default; |
||||
|
|
||||
|
// Constants
|
||||
|
const CONSTANTS = require('../constants'); |
||||
|
|
||||
|
const read = readline.createInterface({ |
||||
|
input: process.stdin, |
||||
|
output: process.stdout |
||||
|
}); |
||||
|
|
||||
|
const createFiles = () => { |
||||
|
return read.questionAsync('Username for your log: ') |
||||
|
.then(answer => { |
||||
|
const markrc = { |
||||
|
username: answer |
||||
|
}; |
||||
|
|
||||
|
return write(CONSTANTS.MARK_RC, JSON.stringify(markrc)); |
||||
|
}) |
||||
|
}; |
||||
|
|
||||
|
const installer = () => { |
||||
|
return open(CONSTANTS.MARK_RC, 'r+') |
||||
|
.catch(createFiles) |
||||
|
}; |
||||
|
|
||||
|
module.exports = installer; |
Loading…
Reference in new issue