diff --git a/app/index.js b/app/index.js index b70998a..e8964d2 100644 --- a/app/index.js +++ b/app/index.js @@ -1,5 +1,6 @@ 'use strict'; var util = require('util'); +var fs = require('fs'); var path = require('path'); var yeoman = require('yeoman-generator'); var _ = require('lodash'); @@ -104,8 +105,9 @@ IonicGenerator.prototype.installStarter = function installStarter() { done(error); } remote.directory('app', 'app'); + this.starterCache = path.join(this.cacheRoot(), this.starter.user, this.starter.repo, 'master'); done(); - }, true); + }.bind(this), true); }; IonicGenerator.prototype.setupEnv = function setupEnv() { @@ -115,6 +117,23 @@ IonicGenerator.prototype.setupEnv = function setupEnv() { this.directory('common/root', '.', true); }; +IonicGenerator.prototype.readIndex = function readIndex() { + this.indexFile = this.read(path.join(this.starterCache, 'index.html')); +}; + +IonicGenerator.prototype.appJs = function appJs() { + var scripts = fs.readdirSync(path.join(process.cwd(), 'app/scripts')); + scripts = _.map(scripts, function (script) { + return 'scripts/' + script; + }); + this.indexFile = this.appendScripts(this.indexFile, 'scripts/scripts.js', scripts); +}; + +IonicGenerator.prototype.createIndexHtml = function createIndexHtml() { + this.indexFile = this.indexFile.replace(/'/g, "'"); + this.write(path.join(this.appPath, 'index.html'), this.indexFile); +}; + IonicGenerator.prototype.copyStyles = function copyStyles() { var sass = this.compass; var mainFile = 'main.' + (sass ? 'sass' : 'css');