-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
25 lines (22 loc) · 689 Bytes
/
index.js
File metadata and controls
25 lines (22 loc) · 689 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
const inquirer = require('inquirer');
const opener = require('opener');
const xray = require('x-ray');
const x = xray();
console.log('Fetching articles');
x('http://medium.freecodecamp.com/', '.postArticle', [{
title: 'h3',
url: '.js-trackedPost > a@href' }])((err, data) => {
const siteChoices = data.map(i => i.title);
const question = {
type: 'list',
name: 'website',
message: 'Pick a website',
choices: siteChoices,
pageSize: 10 };
inquirer.prompt(question)
.then((answer) => {
const website = data.filter(i => i.title === answer.website)[0];
console.log(`Opening "${website.title}"...`);
opener(website.url);
});
});