Skip to content

Commit

Permalink
Add afterInstall to automatically add {{head-layout}} to application.hbs
Browse files Browse the repository at this point in the history
  • Loading branch information
rondale-sc committed Aug 29, 2017
1 parent 1fc2703 commit 9b1fad8
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion blueprints/ember-cli-head/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,27 @@
/*jshint node:true*/
let fs = require('fs');
let path = require('path');
let chalk = require('chalk');

module.exports = {
description: '',
normalizeEntityName: function() { }
normalizeEntityName: function() { },
afterInstall() {
let fullPath = path.join(this.project.root, 'app/templates/application.hbs');

if (fs.existsSync(fullPath)) {
let contents = fs.readFileSync(fullPath, { encoding: 'utf-8' });
let toWrite = `{{head-layout}}\n${contents}`;

fs.writeFileSync(fullPath, toWrite, { encoding: 'utf-8' });
} else {
let str = `You must add {{head-layout}} component to your topmost UI.
This is usually your app/templates/application.hbs, but was not found on your system.
Please see the README for more instructions https://github.com/ronco/ember-cli-head.`

this.ui.writeLine(chalk.yellow(str));
}
}

// locals: function(options) {
// // Return custom template variables here.
Expand Down

0 comments on commit 9b1fad8

Please sign in to comment.