Skip to content

Instantly share code, notes, and snippets.

@fogrew
Last active November 7, 2020 09:08
Show Gist options
  • Save fogrew/e3fcf2c23d6aab7c08d78096bf81c0ca to your computer and use it in GitHub Desktop.
Save fogrew/e3fcf2c23d6aab7c08d78096bf81c0ca to your computer and use it in GitHub Desktop.
get github issues with label
let eventsList = [];
require('./getGithub').then((data) => {
for (event in data) {
eventsList.push({
title: event.title,
url: event.html_url
});
}
console.log(eventsList);
});
const https = require('https');
const defaults = {
host: 'api.github.com',
path: '/repos/nodeschool/spb/issues?state=all&labels=%D0%9C%D0%B5%D1%80%D0%BE%D0%BF%D1%80%D0%B8%D1%8F%D1%82%D0%B8%D0%B5',
headers: {
'User-Agent': 'request'
}
};
const getGithub = function(options) {
Object.assign(defaults, options);
return new Promise((resolve, reject) => {
const request = https.get(options, (response) => {
const body = [];
response.on('data', (chunk) => {
body.push(chunk);
});
response.on('end', () => {
resolve(body.join(''));
});
});
request.on('error', (err) => {
reject(err);
});
});
};
module.exports = getGithub;
const path = require('path');
const data = require('gulp-data');
const nunjucks = require('gulp-nunjucks-render');
var getDataForFile = function(file) {
const variablesFile = path.join(process.cwd(), paths.viewsDir, 'pages', path.dirname(file.relative), 'data.js');
return require(variablesFile);
};
gulp.task('markup', function() {
return gulp.src(paths.dev.pages)
.pipe(data(getDataForFile))
.pipe(nunjucks({
path: paths.viewsDir
}))
.pipe(gulp.dest(paths.dist.pages))
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment