Skip to content

Instantly share code, notes, and snippets.

@vvakame
Created December 30, 2015 09:36
Show Gist options
  • Save vvakame/9d90d7f0130c548ed285 to your computer and use it in GitHub Desktop.
Save vvakame/9d90d7f0130c548ed285 to your computer and use it in GitHub Desktop.
サンプルコードを自動的にPlaygroundで試せるようにするリンク生成する方法思いついた
= クッソ捗る
#@mapoutput(node tsToPlayground.js ./code/ts/letAndConst.ts)
#@end
で、@<code>{review-preproc -r article.re} とかやる。
"use strict";
let fs = require("fs");
let content = fs.readFileSync(process.argv[2], {encoding:"utf8"});
let playgroundURL = `http://www.typescriptlang.org/Playground#src=${encodeURIComponent(content)}`;
let GoogleURL = require("google-url");
new GoogleURL({key: "API Key"}).shorten(playgroundURL, (err, shortURL) => {
if (err) {
process.exit(1);
return;
}
console.log(`@<href>{${shortURL},Playgroundで試す}`);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment