'use strict';
import GenBase from '../genBase';
import mkdirp from 'mkdirp';
import path from 'path';

export default class Generator extends GenBase {
  constructor(...args) {
    super(...args);
  }

  get writing() {
    return function () {
      let config = this.getConfig()
        , elementDir = path.join(config.appDir, 'components', config.hyphenName);

      mkdirp.sync(elementDir);

      if (config.appScript === 'ts') {
        config.referencePath = path.relative(elementDir, config.appDir);
        config.appScript = 'js';
      }

      this.copyStyleFile('element', path.join(elementDir, config.hyphenName + '.' + config.style), config);
      this.copyMarkupFile('element', path.join(elementDir, config.hyphenName + '.' + config.markup), config);
      this.copySrcFile('element', path.join(elementDir, config.hyphenName + '.' + config.appScript), config);
    };
  }
}

@@ -94,16 +94,41 @@
  'path';
+%0Aimport pify from 'pify';
 %0A%0Aexport
@@ -299,16 +299,46 @@
 onfig()%0A
+        , done = this.async()%0A
         
@@ -422,19 +422,20 @@
     
+pify(
 mkdirp
-.sync
+)
 (ele
@@ -442,25 +442,38 @@
 mentDir)
-;%0A
+.then(() =%3E %7B
 %0A      
+  
 if (conf
@@ -493,24 +493,26 @@
 === 'ts') %7B%0A
+  
         conf
@@ -576,24 +576,26 @@
 r);%0A        
+  
 config.appSc
@@ -607,16 +607,18 @@
 = 'js';%0A
+  
       %7D%0A
@@ -620,24 +620,26 @@
    %7D%0A%0A      
+  
 this.copySty
@@ -720,32 +720,34 @@
 tyle), config);%0A
+  
       this.copyM
@@ -842,24 +842,26 @@
 fig);%0A      
+ 
+ 
 this.copySrc
@@ -947,24 +947,51 @@
 t), config);
+%0A%0A        done();%0A      %7D);
 %0A    %7D;%0A  %7D%0A

use async mkdirp method