Skip to content

Instantly share code, notes, and snippets.

@flesch
Last active September 17, 2016 02:24
Show Gist options
  • Save flesch/8ed6f47942350e858ebd3283e10f8a9b to your computer and use it in GitHub Desktop.
Save flesch/8ed6f47942350e858ebd3283e10f8a9b to your computer and use it in GitHub Desktop.
Download a version of the "node-lambda-babel-template".
'use strict';
import { get } from 'gh-got';
// curl -o- https://ribjyr1g9l.execute-api.us-east-1.amazonaws.com/nodelambdababeltemplate/latest | bash
export default async (event, context, callback) => {
const repo = 'node-lambda-babel-template';
const tarball = `https://api.github.com/repos/flesch/${repo}/tarball`;
let { version = 'latest' } = event.params;
if (version === 'latest') {
let { body } = await get(`repos/flesch/${repo}/releases/latest`);
version = body.tag_name;
}
callback(null, `mkdir -p ${repo} && curl -L -o- ${tarball}/${version} | tar zxf - --directory ${repo} --strip-components=1 && cd ${repo}`);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment