Skip to content

Instantly share code, notes, and snippets.

View harrietty's full-sized avatar

Harriet harrietty

View GitHub Profile
const inquirer = require('inquirer');
const fs = require('fs');
const CHOICES = fs.readdirSync(`${__dirname}/templates`);
const QUESTIONS = [
{
name: 'project-choice',
type: 'list',
message: 'What project template would you like to generate?',
const CURR_DIR = process.cwd();
inquirer.prompt(QUESTIONS)
.then(answers => {
const projectChoice = answers['project-choice'];
const projectName = answers['project-name'];
const templatePath = `${__dirname}/templates/${projectChoice}`;
fs.mkdirSync(`${CURR_DIR}/${projectName}`);
function createDirectoryContents (templatePath, newProjectPath) {
const filesToCreate = fs.readdirSync(templatePath);
filesToCreate.forEach(file => {
const origFilePath = `${templatePath}/${file}`;
// get stats about the current file
const stats = fs.statSync(origFilePath);
if (stats.isFile()) {
if (stats.isFile()) {
const contents = fs.readFileSync(origFilePath, 'utf8');
// Rename
if (file === '.npmignore') file = '.gitignore';
const writePath = `${CURR_DIR}/${newProjectPath}/${file}`;
fs.writeFileSync(writePath, contents, 'utf8');
}
module.exports.getdonkeyjobs = (event, context, callback) => {
callback(null, 'Hello world');
};
[
{job: 'Marketing Campaigns Officer', closing: 'Fri Jul 21 2017 00:00:00 GMT+0100', location: 'Leeds, UK'},
{job: 'Registered Veterinary Nurse', closing: 'Sat Jul 22 2017 00:00:00 GMT+0100', location: 'Manchester, UK'},
{job: 'Building Services Manager', closing: 'Fri Jul 21 2017 00:00:00 GMT+0100', location: 'London, UK'}
];
const request = require('axios');
const {extractListingsFromHTML} = require('./helpers');
module.exports.getdonkeyjobs = (event, context, callback) => {
request('https://www.thedonkeysanctuary.org.uk/vacancies')
.then(({data}) => {
const jobs = extractListingsFromHTML(data);
callback(null, {jobs});
})
.catch(callback);
const cheerio = require('cheerio');
const moment = require('moment');
function extractListingsFromHTML (html) {
const $ = cheerio.load(html);
const vacancyRows = $('.view-Vacancies tbody tr');
const vacancies = [];
vacancyRows.each((i, el) => {
service: donkeyjob
provider:
name: aws
runtime: nodejs6.10
functions:
getdonkeyjobs:
handler: handler.getdonkeyjobs
resources:
const request = require('axios');
const AWS = require('aws-sdk');
const dynamo = new AWS.DynamoDB.DocumentClient();
const { differenceWith, isEqual } = require('lodash');
const { extractListingsFromHTML } = require('./helpers');
module.exports.getdonkeyjobs = (event, context, callback) => {
let newJobs, allJobs;
request('https://www.thedonkeysanctuary.org.uk/vacancies')