├── .gitignore ├── labels ├── packages │ ├── type.json │ └── status.json └── make.js ├── index.js ├── package.json ├── LICENSE ├── readme.md └── make-me-lol.js /.gitignore: -------------------------------------------------------------------------------- 1 | /node_modules/ 2 | /.env.js 3 | -------------------------------------------------------------------------------- /labels/packages/type.json: -------------------------------------------------------------------------------- 1 | [ 2 | { "name": "Type: Bug", "color": "#e11d21" }, 3 | { "name": "Type: Maintenance", "color": "#fbca04" }, 4 | { "name": "Type: Enhancement", "color": "#84b6eb" }, 5 | { "name": "Type: Question", "color": "#cc317c" } 6 | ] 7 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | var exec = require('child_process').exec; 3 | var path = require('path'); 4 | 5 | var relPath = __dirname + '/make-me-lol.js'; 6 | relPath = relPath.replace(/\\/g, '/'); 7 | 8 | var flags = process.argv.splice(2).join(' '); 9 | 10 | exec('node --harmony ' + relPath + ' ' + flags, function(error, stdout, stderr) { 11 | console.log(stdout); 12 | console.error(stderr); 13 | if (error) { 14 | console.error(error); 15 | } 16 | }); 17 | -------------------------------------------------------------------------------- /labels/make.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | require('../.env.js'); // sets the environment variables 3 | 4 | const gitLabel = require('git-label'), 5 | config = { 6 | api : 'https://api.github.com', 7 | repo : 'himynamei/make-me-lol', 8 | token : process.env.GIT_LABEL_TOKEN 9 | }, 10 | packages = ['labels/packages/status.json', 'labels/packages/type.json']; 11 | 12 | gitLabel.add(config, packages) 13 | .then(console.log) 14 | .catch(console.log); 15 | -------------------------------------------------------------------------------- /labels/packages/status.json: -------------------------------------------------------------------------------- 1 | [ 2 | { "name": "Status: Abandoned", "color": "#000000" }, 3 | { "name": "Status: Accepted", "color": "#009800" }, 4 | { "name": "Status: Available", "color": "#bfe5bf" }, 5 | { "name": "Status: Blocked", "color": "#e11d21" }, 6 | { "name": "Status: Completed", "color": "#006b75" }, 7 | { "name": "Status: In Progress", "color": "#cccccc" }, 8 | { "name": "Status: On Hold", "color": "#e11d21" }, 9 | { "name": "Status: Pending", "color": "#fef2c0" }, 10 | { "name": "Status: Review Needed", "color": "#fbca04" }, 11 | { "name": "Status: Revision Needed", "color": "#e11d21" } 12 | ] 13 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "make-me-lol", 3 | "version": "0.2.1", 4 | "description": "A command-line tool to make you laugh.", 5 | "main": "index.js", 6 | "scripts": { 7 | "postinstall": "cp -R node_modules/git-label-packages/packages/status.json node_modules/git-label-packages/packages/type.json labels/packages" 8 | }, 9 | "engines": { 10 | "node": ">= 0.10.5" 11 | }, 12 | "repository": { 13 | "type": "git", 14 | "url": "git+https://github.com/himynameisdave/make-me-lol.git" 15 | }, 16 | "keywords": [ 17 | "fun", 18 | "command-line", 19 | "cli", 20 | "gifs", 21 | "videos", 22 | "lols" 23 | ], 24 | "bin": { 25 | "make-me-lol": "./index.js" 26 | }, 27 | "author": "Dave Lunny", 28 | "license": "MIT", 29 | "bugs": { 30 | "url": "https://github.com/himynameisdave/make-me-lol/issues" 31 | }, 32 | "homepage": "https://github.com/himynameisdave/make-me-lol#readme", 33 | "dependencies": { 34 | "commander": "^2.9.0", 35 | "git-label": "^3.3.0", 36 | "git-label-packages": "^1.1.0", 37 | "open": "0.0.5", 38 | "request-promise": "^1.0.2" 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Dave Lunny 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | ### make-me-lol 2 | 3 | A command-line tool to make you laugh. Because who doesn't like to laugh, amirite? :stuck_out_tongue: All ya gotta do is type the command and it opens a random funny picture, gif or video from Reddit. 4 | 5 | ![example](http://i.imgur.com/2fHBaxQ.gif) 6 | 7 | **Install** 8 | 9 | ``` 10 | npm i -g make-me-lol 11 | ``` 12 | 13 | You gotta have at least `node v4.0.0` or an [`--harmony` node version](https://nodejs.org/en/docs/es6/) (tested in v0.12.7) for this to work, cause it's pretty ES6exy with its use of [Promises](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Promise) and all. 14 | 15 | 16 | **Usage** 17 | 18 | Dead simple all you gotta do is run: 19 | 20 | ``` 21 | make-me-lol [options or no options its cool] 22 | ``` 23 | 24 | **Options** 25 | 26 | ``` 27 | -h, --help output usage information 28 | -V, --version output the version number 29 | -v, --video opens a funny video 30 | -g, --gif opens a funny gif 31 | -p, --pic opens a funny pic 32 | -q, --quiet opens a funny not video 33 | -o, --output output only without opening 34 | ``` 35 | 36 | **Contribute** 37 | 38 | Feel free to open [an issue](https://github.com/himynameisdave/make-me-lol/issues/new) or [pull request](https://github.com/himynameisdave/make-me-lol/compare?expand=1)! 39 | 40 | --- 41 | 42 | *Licenced under MIT (c) Made by [Dave Lunny](https://twitter.com/dave_lunny) in the beautiful year 2015* 43 | -------------------------------------------------------------------------------- /make-me-lol.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | "use strict"; 3 | const commander = require("commander"); 4 | const request = require("request-promise"); 5 | const version = require("./package.json").version; 6 | const open = require("open"); 7 | const redditUrls = [ 8 | "https://www.reddit.com/r/funnyvideos/.json", 9 | "https://www.reddit.com/r/Funnypics/.json", 10 | "https://www.reddit.com/r/funnygifs/.json", 11 | "https://www.reddit.com/r/Funny/.json" 12 | ]; 13 | // Register arguments with commander 14 | commander.version(version) 15 | .option('-v, --video', 'opens a funny video') 16 | .option('-g, --gif', 'opens a funny gif') 17 | .option('-p, --pic', 'opens a funny pic') 18 | .option('-q, --quiet', 'opens a funny not video') 19 | .option('-o, --output','output only without opening') 20 | .parse(process.argv); 21 | 22 | // Sets the lookup url based on command line arguments 23 | let funUrl = redditUrls[3]; 24 | if( commander.video ){ 25 | funUrl = redditUrls[0]; 26 | } 27 | if( commander.pic ){ 28 | funUrl = redditUrls[1]; 29 | } 30 | if( commander.gif ){ 31 | funUrl = redditUrls[2]; 32 | } 33 | if( commander.quiet ){ 34 | funUrl = redditUrls[Math.floor(Math.random()*redditUrls.length)+1]; 35 | } 36 | 37 | console.log('Get ready to lol...'); 38 | // Go get our JSON data 39 | request(funUrl) 40 | .then( data => { 41 | let parsed = JSON.parse(data).data.children, 42 | l = parsed.length, 43 | n = Math.floor(Math.random() * (l - 1)) + 1; 44 | if( commander.quiet && parsed[n].data.domain.indexOf("youtube") > -1 ){ 45 | n = Math.floor(Math.random() * (l - 1)) + 1; 46 | }; 47 | // open our funny url 48 | if( !commander.output ){ 49 | return open(parsed[n].data.url); 50 | }else{ 51 | console.log("Your lol can be found over here:\n"+parsed[n].data.url); 52 | } 53 | process.exit(1); 54 | }) 55 | .catch( err => { 56 | console.warn(err); 57 | process.exit(0); 58 | }); 59 | --------------------------------------------------------------------------------