Skip to content

Commit

Permalink
Add blueprint to add ember-basic-dropdown style dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
Francesco Novy committed Apr 12, 2017
1 parent 23452c8 commit 2892f5a
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 2 deletions.
39 changes: 39 additions & 0 deletions blueprints/ember-date-components/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/* eslint-env node */
'use strict';

const path = require('path');
const fs = require('fs');

module.exports = {
normalizeEntityName() {
// this prevents an error when the entityName is
// not specified (since that doesn't actually matter
// to us
},

afterInstall() {
let dependencies = this.project.dependencies();
let type;
let importStatement = "\n@import 'ember-basic-dropdown';\n";

if ('ember-cli-sass' in dependencies) {
type = 'scss';
}

if (type) {
let stylePath = path.join('app', 'styles');
let file = path.join(stylePath, `app.${type}`);

if (!fs.existsSync(stylePath)) {
fs.mkdirSync(stylePath);
}
if (fs.existsSync(file)) {
this.ui.writeLine(`Added import statement to ${file}`);
return this.insertIntoFile(file, importStatement, {});
} else {
fs.writeFileSync(file, importStatement);
this.ui.writeLine(`Created ${file}`);
}
}
}
};
7 changes: 5 additions & 2 deletions tests/dummy/app/index/template.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,13 @@ var app = new EmberApp({

<p>
You are encouraged to overwrite the styles to fit your app.
If you use Sass, you can also import a provided partial:
If you use Sass, you can also import a provided partial (don't forget to disable the CSS import in that case!).
You'll also need to ensure that the ember-basic-dropdown partial is correctly imported. If you don't use Sass,
it will automatically be added to your project (via the ember-basic-dropdown addon).
</p>

{{#code-block language='scss'}}@import "ember-date-components/addon";{{/code-block}}
{{#code-block language='scss'}}@import "ember-basic-dropdown";
@import "ember-date-components/addon";{{/code-block}}

<p>
This partial uses a few variables that you can set:
Expand Down

0 comments on commit 2892f5a

Please sign in to comment.