Browse Source

[installer] Added working installer

master
Muthu Kumar 7 years ago
parent
commit
658180d256
  1. 22
      index.js
  2. 35
      lib/installer.js

22
index.js

@ -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;

35
lib/installer.js

@ -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…
Cancel
Save