'use strict';
var util = require('util');
var chdir = require('chdir');
var path = require('path');
// var spawn = require('child_process').spawn;
var yeoman = require('yeoman-generator');


var SiteGenerator = module.exports = function SiteGenerator(args, options, config) {
  yeoman.generators.Base.apply(this, arguments);

  this.on('end', function () {
    // https://github.com/yeoman/generator/issues/282
    chdir('./tools', function () {
      this.installDependencies({ skipInstall: options['skip-install'] });
    }.bind(this));
  });

  this.appPath = process.cwd();

  // this.pkg = JSON.parse(this.readFileAsString(path.join(__dirname, '../package.json')));
};

util.inherits(SiteGenerator, yeoman.generators.Base);

SiteGenerator.prototype.askFor = function askFor() {
  // welcome message
  console.log(this.yeoman);
};

SiteGenerator.prototype.gruntfile = function gruntfile() {
  this.copy('Gruntfile.coffee', 'tools/Gruntfile.coffee');
};

SiteGenerator.prototype.packageJSON = function packageJSON() {
  this.template('_package.json', 'tools/package.json');
};

SiteGenerator.prototype.rootconfig = function rootconfig() {
  this.copy('gitignore', '.gitignore');
  this.copy('editorconfig', '.editorconfig');
};

SiteGenerator.prototype.bower = function bower() {
  this.copy('bowerrc', 'tools/.bowerrc');
  this.copy('_bower.json', 'tools/bower.json');
};

SiteGenerator.prototype.jshint = function jshint() {
  this.copy('jshintrc', 'tools/.jshintrc');
};

SiteGenerator.prototype.csslint = function csslint() {
  this.copy('csslintrc', 'tools/.csslintrc');
};

SiteGenerator.prototype.stylesheet = function stylesheet() {
  this.directory('sass', 'htdocs/_scss');
  this.template('config.rb', 'tools/config.rb');
};

SiteGenerator.prototype.htmlTmpl = function htmlTmpl() {
  this.copy('index.html', 'htdocs/index.html');
};

SiteGenerator.prototype.app = function app() {
  this.mkdir('htdocs');
  this.mkdir('htdocs/common');
  this.mkdir('htdocs/common/js');
  this.mkdir('htdocs/common/css');
  this.mkdir('htdocs/common/images');
  this.mkdir('materials');
  this.mkdir('backup');
  this.mkdir('test');
  this.mkdir('test/validator');
};

@@ -69,83 +69,8 @@
 ');%0A
-var path = require('path');%0A// var spawn = require('child_process').spawn;%0A
 var 
@@ -108,17 +108,16 @@
 tor');%0A%0A
-%0A
 var Site
@@ -289,30 +289,55 @@
 http
-s
 ://
-github.com
+stackoverflow.com/questions/22361446
 /yeoman
-/
+-
 gene
@@ -345,61 +345,280 @@
 ator
-/issues/282%0A    chdir('./tools', function () %7B%0A 
+-installing-project-dependencies-in-custom-folder%0A    // http://stackoverflow.com/questions/18841273/how-to-run-a-grunt-task-after-my-yeoman-generator-finishes-installing%0A    var approot = process.cwd();%0A    var npmdir = approot + '/tools';%0A    process.chdir(npmdir);%0A
     
- 
 this
@@ -639,16 +639,22 @@
 encies(%7B
+%0A     
  skipIns
@@ -686,29 +686,85 @@
 ll'%5D
- %7D);%0A    %7D.bind(this)
+,%0A      callback: function () %7B%0A        process.chdir(approot);%0A      %7D%0A    %7D
 );%0A 

Change main script chdir logic