mirror of https://github.com/codefeathers/mark
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
700 B
35 lines
700 B
// 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;
|