Thread overview
typescript plugin for vibe.d diet templates
Jan 17, 2015
Mengu
Jan 17, 2015
Marc Schütz
Jan 17, 2015
Fatih Kadir Akin
Jan 18, 2015
Jacob Carlborg
Jan 18, 2015
Marc Schütz
Jan 19, 2015
Ali Çehreli
January 17, 2015
a friend of mine liked d so much -you know, after i show off all the kewl features :)- he just built a typescript plugin for vibe.d diet templates. it's a fork of martin's coffeescript plugin.

https://github.com/f/diet-typescript

for the uninformed, typescript is a typed superset of javascript that compiles to plain old javascript. more info can be reached at www.typescriptlang.org.
January 17, 2015
On Saturday, 17 January 2015 at 11:26:40 UTC, Mengu wrote:
> a friend of mine liked d so much -you know, after i show off all the kewl features :)- he just built a typescript plugin for vibe.d diet templates. it's a fork of martin's coffeescript plugin.
>
> https://github.com/f/diet-typescript
>
> for the uninformed, typescript is a typed superset of javascript that compiles to plain old javascript. more info can be reached at www.typescriptlang.org.

Nice work, but I have some gripes with it:

First, creating temporary files with predictable names is a bad idea, because it opens the door for symlink attacks. Unfortunately, I don't know of an alternative way to do this safely using only the standard library; it seems, this crucial functionality is missing. I've asked here:

http://forum.dlang.org/thread/xliylzcxrsfilmqsncxf@forum.dlang.org

The second thing is that you're using `pipeShell()`, which takes only the entire command as a parameter. Because this command will be interpreted by the shell, you have to make sure that all you're arguments are correctly escaped. However, in your case you don't actually need a shell; `pipeProcess()` is a better solution, because it takes the argument list as an array:

    auto pipes = pipeProcess(
        ["tsc", inputFileName, "--out", outputFileName],
        Redirect.stderrToStdout | Redirect.stdout
    );
January 17, 2015
> First, creating temporary files with predictable names is a bad idea, because it opens the door for symlink attacks. Unfortunately, I don't know of an alternative way to do this safely using only the standard library; it seems, this crucial functionality is missing. I've asked here:

TypeScript compiler doesn't accept stdin pipes, I tried using Unix fifo but since I'm not an Unix expert, couldn't figure it out. The last thing was using a temporary file -- which also sounds not good to me :)

> The second thing is that you're using `pipeShell()`, which takes only the entire command as a parameter. Because this command will be interpreted by the shell, you have to make sure that all you're arguments are correctly escaped. However, in your case you don't actually need a shell; `pipeProcess()` is a better solution, because it takes the argument list as an array:
>
>     auto pipes = pipeProcess(
>         ["tsc", inputFileName, "--out", outputFileName],
>         Redirect.stderrToStdout | Redirect.stdout
>     );

It really makes sense, I'm going to update -- you also can open a PR.

I met the language yesterday, I wrote the package yesterday :) I don't know internals, but when I learn them, (which is happening by now) going to fix it,

Thanks for your detailed comments! :)
January 18, 2015
On 2015-01-17 19:24, Fatih Kadir Akin wrote:

> TypeScript compiler doesn't accept stdin pipes, I tried using Unix fifo
> but since I'm not an Unix expert, couldn't figure it out. The last thing
> was using a temporary file -- which also sounds not good to me :)

How about embedding the TypeScript compiler and call it from D, perhaps using DMDScript [1].

[1] http://code.dlang.org/packages/dmdscript

-- 
/Jacob Carlborg
January 18, 2015
On Saturday, 17 January 2015 at 18:24:52 UTC, Fatih Kadir Akin wrote:
>
>> First, creating temporary files with predictable names is a bad idea, because it opens the door for symlink attacks. Unfortunately, I don't know of an alternative way to do this safely using only the standard library; it seems, this crucial functionality is missing. I've asked here:
>
> TypeScript compiler doesn't accept stdin pipes, I tried using Unix fifo but since I'm not an Unix expert, couldn't figure it out. The last thing was using a temporary file -- which also sounds not good to me :)

I was going to make a PR to use pipes, but also found that `tsc` sadly doesn't support stdin/stdout. But they have an as-of-yet unimplemented enhancement request; they probably wouldn't refuse a PR:
https://github.com/Microsoft/TypeScript/issues/1226

As for FIFOs, they unfortunately don't work on Windows... (and NTFS _does_ support symlinks!)

>
>> The second thing is that you're using `pipeShell()`, which takes only the entire command as a parameter. Because this command will be interpreted by the shell, you have to make sure that all you're arguments are correctly escaped. However, in your case you don't actually need a shell; `pipeProcess()` is a better solution, because it takes the argument list as an array:
>>
>>    auto pipes = pipeProcess(
>>        ["tsc", inputFileName, "--out", outputFileName],
>>        Redirect.stderrToStdout | Redirect.stdout
>>    );
>
> It really makes sense, I'm going to update -- you also can open a PR.
>

https://github.com/f/diet-typescript/pull/1
January 19, 2015
On 01/17/2015 10:24 AM, Fatih Kadir Akin wrote:

> I met the language yesterday, I wrote the package yesterday :)

I'm in awe! :)

Ali