add typescript node

This commit is contained in:
Dan Vargas 2022-02-06 13:58:02 -07:00
parent 60296ccd26
commit 59f164c48c
2 changed files with 41 additions and 0 deletions

View File

@ -18,4 +18,5 @@ args: {
"zig" = import ./zig.nix args;
"vlang" = import ./vlang.nix args;
"swift" = import ./swift.nix args;
"node-typescript" = import ./node-typescript.nix args;
}

View File

@ -0,0 +1,40 @@
{pkgs, piston, ...}:
let
node = pkgs.nodejs;
pkg = pkgs.nodePackages.typescript;
in piston.mkRuntime {
language = "typescript";
version = pkg.version;
runtime = "node";
aliases = [
"ts"
"node-ts"
"tsc"
];
compile = ''
rename 's/$/.ts/' "$@" # Add .ts extension
${pkg}/bin/tsc *.ts
'';
run = ''
code="$1.js"
shift
${node}/bin/node "$code" "$@"
'';
tests = [
(piston.mkTest {
files = {
"test.js" = ''
console.log("OK");
'';
};
args = [];
stdin = "";
packages = [];
main = "test.js";
})
];
}