Skip to content

Commit

Permalink
Update 3.0.0 🔥
Browse files Browse the repository at this point in the history
  • Loading branch information
xxczaki authored Feb 12, 2018
1 parent 457c5cd commit 0189566
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 11 deletions.
25 changes: 19 additions & 6 deletions lib/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const homeDir = require('os').homedir();
const chalk = require('chalk');
const clipboardy = require('clipboardy');
const opn = require('opn');
const logSymbols = require('log-symbols');
const inquirer = require('inquirer');

// Little helper
Expand Down Expand Up @@ -90,7 +91,7 @@ module.exports.create = () => {
when: a => {
if (a.copy) {
clipboardy.write(this.emoji);
console.log(chalk.green.bold('Emoticon copied to clipboard!'));
console.log(chalk.green.bold(`${logSymbols.success} Emoticon copied to clipboard!`));
}
return true;
}
Expand All @@ -99,7 +100,7 @@ module.exports.create = () => {
}).then(a => {
if (a.save) {
fs.writeFileSync(`${homeDir}/saved_emoji.txt`, `\n${this.emoji}`, {flag: 'a'});
console.log(chalk.green.bold(`Emoticon saved in ${homeDir}!`));
console.log(chalk.green.bold(`${logSymbols.success} Emoticon saved in ${homeDir}!`));
}
});
};
Expand Down Expand Up @@ -146,15 +147,15 @@ module.exports.random = () => {
when: a => {
if (a.copy) {
clipboardy.write(this.emoji);
console.log(chalk.green.bold('Emoticon copied to clipboard!'));
console.log(chalk.green.bold(`${logSymbols.success} Emoticon copied to clipboard!`));
}
return true;
}
}
]).then(a => {
if (a.save) {
fs.writeFileSync(`${homeDir}/saved_emoji.txt`, `\n${this.emoji}`, {flag: 'a'});
console.log(chalk.green.bold(`Emoticon saved in ${homeDir}!`));
console.log(chalk.green.bold(`${logSymbols.success} Emoticon saved in ${homeDir}!`));
}
});
};
Expand All @@ -166,7 +167,7 @@ module.exports.get = () => {
emojiList = fs.readFileSync(`${homeDir}/saved_emoji.txt`, 'utf8').split('\n');
} catch (err) {
if (err.code === 'ENOENT') {
console.log(chalk.red(`Emoticon not found in ${homeDir}/saved_emoji.txt :(`));
console.log(chalk.red(`${logSymbols.error} Emoticons not found in ${homeDir}/saved_emoji.txt :(`));
return;
}
}
Expand All @@ -179,7 +180,7 @@ module.exports.get = () => {
}
]).then(a => {
clipboardy.write(a.emoji);
console.log(chalk.green.bold('Emoticon copied to clipboard!'));
console.log(chalk.green.bold(`${logSymbols.success} Emoticon copied to clipboard!`));
});
};

Expand All @@ -188,6 +189,18 @@ module.exports.bug = () => { // Report bug prompt
process.exit();
};

module.exports.delete = () => { // Delete saved emoticons
try {
fs.unlinkSync(`${homeDir}/saved_emoji.txt`);
console.log(chalk.green.bold(`${logSymbols.success} Successfully deleted all saved emoticons!`));
return;
} catch (err) {
if (err.code === 'ENOENT') {
console.log(chalk.red(`${logSymbols.error} File ${homeDir}/saved_emoji.txt not found :(`));
}
}
};

module.exports.exit = () => { // Exit message
console.log(chalk.magenta.bold('See you next time! ♡'));
process.exit();
Expand Down
12 changes: 8 additions & 4 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,22 @@ function showMenu() {
value: 'create'
},
{
name: 'Create new random emoticon',
name: 'Create random emoticon',
value: 'random'
},
{
name: 'Copy saved emoticon',
name: 'Copy saved emoticons',
value: 'get'
},
{
name: 'Report bug',
value: 'bug'
name: 'Delete saved emoticons',
value: 'delete'
},
new inquirer.Separator(),
{
name: `${chalk.yellow('Report bug')}`,
value: 'bug'
},
{
name: `${chalk.red('Exit')}`,
value: 'exit'
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "oji",
"version": "2.2.0",
"version": "3.0.0",
"description": "(◕‿◕) Text Emoticon Maker",
"bin": {
"oji": "./bin/cli"
Expand All @@ -10,6 +10,7 @@
"chalk": "^2.3.0",
"clipboardy": "^1.2.2",
"inquirer": "^5.1.0",
"log-symbols": "^2.2.0",
"opn": "^5.2.0"
},
"devDependencies": {
Expand Down

0 comments on commit 0189566

Please sign in to comment.