Skip to content

Commit 9b1fad8

Browse files
committed
Add afterInstall to automatically add {{head-layout}} to application.hbs
1 parent 1fc2703 commit 9b1fad8

1 file changed

Lines changed: 21 additions & 1 deletion

File tree

blueprints/ember-cli-head/index.js

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,27 @@
11
/*jshint node:true*/
2+
let fs = require('fs');
3+
let path = require('path');
4+
let chalk = require('chalk');
5+
26
module.exports = {
37
description: '',
4-
normalizeEntityName: function() { }
8+
normalizeEntityName: function() { },
9+
afterInstall() {
10+
let fullPath = path.join(this.project.root, 'app/templates/application.hbs');
11+
12+
if (fs.existsSync(fullPath)) {
13+
let contents = fs.readFileSync(fullPath, { encoding: 'utf-8' });
14+
let toWrite = `{{head-layout}}\n${contents}`;
15+
16+
fs.writeFileSync(fullPath, toWrite, { encoding: 'utf-8' });
17+
} else {
18+
let str = `You must add {{head-layout}} component to your topmost UI.
19+
This is usually your app/templates/application.hbs, but was not found on your system.
20+
Please see the README for more instructions https://github.com/ronco/ember-cli-head.`
21+
22+
this.ui.writeLine(chalk.yellow(str));
23+
}
24+
}
525

626
// locals: function(options) {
727
// // Return custom template variables here.

0 commit comments

Comments
 (0)