jashkenas/coffee-script — Issue #2027: `mkdir -p` doesn't work as expected on windows
Author: ajmh
Created: 2012-01-11 20:22:00+00:00
State: open

The `mkdir -p` call in the `writeJs()` method in `lib/coffee-script/command.js` does not work as expected on Windows when using the `coffee` compiler on a source tree with sub-directories - it will actually create a new directory `-p` in the current working directory of the console environment instead.

Here is the code from the current master branch causing the problem:

```javascript
return exec("mkdir -p " + jsDir, compile);
```

The recursive path creation behavior desired is natively available in Windows with `mkdir` if `Command Extensions` are enabled (which they are by default). Here is the [MS documentation](http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/mkdir.mspx) for `mkdir` on WinXP (seems to apply for Win7+ as well).

Perhaps this could check the `process.platform` flag for the Windows platform and omit the `-p` flag?

```javascript
// ... somewhere early on - pre-set flag use for local platform
var mkdirFlag = '-p';
// Check for windows platform to vet flag
if (process.platform.substr(0,3) === 'win') {
mkdirFlag = '';
}
// ... code ...
return exec("mkdir " + mkdirFlag + " " + jsDir, compile);
```