import Bluebird from "bluebird" ; import Handlebars from "handlebars" ; import request from "request" ; import { readFile , writeFile } from "./lib/utility/fs" ; import { execSync } from "child_process" ; Handlebars . registerHelper ( "bash" , ( command ) => { return execSync ( command ) . toString ( "ascii" ) ; } ) ; async function fromGithub ( endpoint ) { return Bluebird . promisify ( request ) ( { method : "GET" , url : "https://api.github.com/" + endpoint , json : true , headers : { "User-Agent" : "README generator" } } ) . then ( ( response ) => response . body ) ; } Promise . all ( [ readFile ( "./README.handlebars" , "utf8" ) , fromGithub ( "repos/2fd/graphdoc" ) , fromGithub ( "repos/2fd/graphdoc/contributors" ) . then ( ( contributors ) => contributors . filter ( c => c . login !== "2fd" ) ) ] ) . then ( ( [ template , project , contributors ] ) => { return writeFile ( "README.md" , Handlebars . compile ( template ) ( { project , contributors } ) ) ; } ) ;