Skip to content

Commit

Permalink
feat(generator): Dynamically scaffold index.html file
Browse files Browse the repository at this point in the history
  • Loading branch information
diegonetto committed Jul 29, 2014
1 parent 34184bb commit ce534bc
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion app/index.js
Original file line number Diff line number Diff line change
@@ -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');
Expand Down Expand Up @@ -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() {
Expand All @@ -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');
Expand Down

0 comments on commit ce534bc

Please sign in to comment.