import Promise from 'es6-promise/lib/es6-promise/promise';
import * as fs from 'fs';
import { resolve } from './path';

export function writeFile ( dest, data ) {
	return new Promise( ( fulfil, reject ) => {
		fs.writeFile( resolve( process.cwd(), dest ), data, err => {
			if ( err ) {
				reject( err );
			} else {
				fulfil();
			}
		});
	});
}

export const readdirSync = fs.readdirSync;
export const readFileSync = fs.readFileSync;

@@ -87,22 +87,22 @@
 mport %7B 
-resolv
+dirnam
 e %7D from
@@ -113,16 +113,176 @@
 path';%0A%0A
+function mkdirpath ( path ) %7B%0A%09const dir = dirname( path );%0A%09try %7B%0A%09%09fs.readdirSync( dir );%0A%09%7D catch ( err ) %7B%0A%09%09mkdirpath( dir );%0A%09%09fs.mkdirSync( dir );%0A%09%7D%0A%7D%0A%0A
 export f
@@ -367,52 +367,48 @@
 %7B%0A%09%09
-fs.writeFile( resolve( process.cwd(),
+mkdirpath( dest );%0A%0A%09%09fs.writeFile(
  dest
- )
 , da

make intermediate dirs in writeFile helper