-
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.
Add copy to clipboard and colors to cli output
- Loading branch information
1 parent
cdabb7d
commit eb8f48b
Showing
4 changed files
with
51 additions
and
25 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
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,10 +1,32 @@ | ||
#!/usr/bin/env node | ||
|
||
const angularReleaseNameGenerator = require('./lib'); | ||
|
||
angularReleaseNameGenerator() | ||
.then(({ version, name, gif }) => { | ||
console.log('Release name: Angular ' + version + ' - ' + name); | ||
console.log(gif); | ||
}) | ||
.catch(error => console.error(error.message)); | ||
const chalk = require('chalk'); | ||
const writeToClipboard = require('clipboardy').write; | ||
|
||
const releaseNameGenerator = require('./lib'); | ||
|
||
function multiline(...lines) { return lines.join('\r\n'); } | ||
|
||
function log(lines, type = 'log') { | ||
console[type](multiline(...[chalk.dim('----------')].concat(lines))); | ||
} | ||
|
||
function successLog(message) { | ||
log(chalk.green(message), 'info'); | ||
} | ||
|
||
function errorLog(message) { | ||
log(chalk.red(message), 'error'); | ||
} | ||
|
||
function logResult({ version, name, gif }) { | ||
const release = 'Angular ' + version + ' - ' + name; | ||
log([chalk.white.bgRed.bold(release), chalk.blue.underline(gif)]); | ||
return multiline(release, gif); | ||
} | ||
|
||
releaseNameGenerator() | ||
.then(logResult) | ||
.then(writeToClipboard) | ||
.then(() => successLog('Copied to clipboard')) | ||
.catch(error => errorLog(error.message)); |
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
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,34 +1,36 @@ | ||
{ | ||
"name": "angular-release-name-generator", | ||
"description": "Generate random Angular release names", | ||
"main": "./lib.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"version": "1.1.0", | ||
"version": "1.2.0", | ||
"license": "MIT", | ||
"author": "https://github.com/sebastien-p", | ||
"contributors": ["https://github.com/known-as-bmf"], | ||
"keywords": ["angular"], | ||
"homepage": "https://github.com/sebastien-p/angular-release-name-generator#readme", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/sebastien-p/angular-release-name-generator.git" | ||
}, | ||
"keywords": ["angular"], | ||
"author": "https://github.com/sebastien-p", | ||
"contributors": ["https://github.com/known-as-bmf"], | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/sebastien-p/angular-release-name-generator/issues" | ||
}, | ||
"preferGlobal": true, | ||
"engines": { | ||
"node": ">=6.4.0" | ||
}, | ||
"main": "./lib.js", | ||
"bin": { | ||
"arng": "./cli.js" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/sebastien-p/angular-release-name-generator/issues" | ||
}, | ||
"homepage": "https://github.com/sebastien-p/angular-release-name-generator#readme", | ||
"dependencies": { | ||
"chalk": "2.3.0", | ||
"clipboardy": "1.2.1", | ||
"datamuse": "1.0.5", | ||
"giphy-api": "1.2.7", | ||
"lodash": "4.17.4", | ||
"semver": "5.4.1" | ||
}, | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
} | ||
} |