Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates #73

Merged
merged 6 commits into from
Sep 5, 2018
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# unconventional js
/blueprints/*/files/
/vendor/

# compiled output
/dist/
/tmp/

# dependencies
/bower_components/

# misc
/coverage/

# ember-try
/.node_modules.ember-try/
6 changes: 4 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,17 @@ module.exports = {
// node files
{
files: [
'ember-cli-build.js',
'index.js',
'testem.js',
'ember-cli-build.js',
'blueprints/*/index.js',
'config/**/*.js',
'tests/dummy/config/**/*.js'
],
excludedFiles: [
'app/**',
'addon/**',
'addon-test-support/**',
'app/**',
'tests/dummy/app/**'
],
parserOptions: {
Expand Down
22 changes: 11 additions & 11 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
# See https://help.github.com/ignore-files/ for more about ignoring files.

# compiled output
/dist
/tmp
/dist/
/tmp/

# dependencies
/node_modules
/bower_components
/bower_components/
/node_modules/

# misc
/.sass-cache
/connect.lock
/coverage/*
/coverage/
/libpeerconnection.log
npm-debug.log*
yarn-error.log
testem.log
/npm-debug.log*
/testem.log
/yarn-error.log

# ember-try
.node_modules.ember-try/
bower.json.ember-try
package.json.ember-try
/.node_modules.ember-try/
/bower.json.ember-try
/package.json.ember-try
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
bower.json
ember-cli-build.js
testem.js
yarn.lock

# ember-try
.node_modules.ember-try/
Expand Down
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,5 @@ script:
- npm run lint:js
# Usually, it's ok to finish the test scenario without reverting
# to the addon's original dependency state, skipping "cleanup".
- node_modules/.bin/ember try:one $EMBER_TRY_SCENARIO --skip-cleanup
# - node_modules/.bin/ember try:one $EMBER_TRY_SCENARIO --skip-cleanup
- npm test
42 changes: 38 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@

Take a single favicon source file at `public/favicon.png`, and convert to the various formats and sizes required for popular devices and platforms. Also injects the appropriate HTML into your index.html file during the build process.

## Installation
Installation
------------------------------------------------------------------------------

```sh
$ ember install ember-cli-favicon
```
ember install ember-cli-favicon
```

## Usage
Usage
------------------------------------------------------------------------------

Just save an image to `public/favicon.png` (try to make sure it's at least 256x256). Additional configuration options are supplied in your `ember-cli-build.js` file:

Expand All @@ -28,3 +30,35 @@ var app = new EmberApp({

See the [favicons](https://github.com/haydenbleasel/favicons) module for details on the available configuration options.


Contributing
------------------------------------------------------------------------------

### Installation

* `git clone https://github.com/davewasmer/broccoli-favicon`
* `cd ember-cli-favicon`
* `npm install`

### Linting

* `npm run lint:js`
* `npm run lint:js -- --fix`

### Running tests

* `ember test` – Runs the test suite on the current Ember version
* `ember test --server` – Runs the test suite in "watch mode"
* `ember try:each` – Runs the test suite against multiple Ember versions

### Running the dummy application

* `ember serve`
* Visit the dummy application at [http://localhost:4200](http://localhost:4200).

For more information on using ember-cli, visit [https://ember-cli.com/](https://ember-cli.com/).

License
------------------------------------------------------------------------------

This project is licensed under the [MIT License](LICENSE.md).
2 changes: 1 addition & 1 deletion config/ember-try.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module.exports = function() {
return Promise.all([
getChannelURL('release'),
getChannelURL('beta'),
getChannelURL('canary'),
getChannelURL('canary')
]).then((urls) => {
return {
scenarios: [
Expand Down
32 changes: 21 additions & 11 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,36 @@ const mergeTrees = require('broccoli-merge-trees');
let htmlCache = null;

module.exports = {

name: 'ember-cli-favicon',

included(app) {
let options = app.options;
included(parent) {
// Support for fingerprint
parent.options.fingerprint = parent.options.fingerprint || {};
parent.options.fingerprint.exclude = parent.options.fingerprint.exclude || [];
parent.options.fingerprint.exclude.push('apple-touch-icon', 'favicon', 'mstile');

// Set success callback
parent.options.favicons = parent.options.favicons || {};

let fingerprint = options.fingerprint = options.fingerprint || {};
fingerprint.exclude = fingerprint.exclude || [];
fingerprint.exclude.push('apple-touch-icon', 'favicon', 'mstile');
let currentCallback = parent.options.favicons.htmlCallback || function() {};

this.options = options.favicons || {};
this.options.htmlCallback = function(html) {
parent.options.favicons.htmlCallback = function(html) {
htmlCache = html;
return currentCallback(...arguments);
};

this.parentOptions = parent.options;

return this._super.included(parent);
},

treeForPublic(tree) {
let faviconTree = new Favicons(this.parentOptions.trees.public, this.parentOptions.favicons);
return mergeTrees([ faviconTree, tree ].filter((v) => v), { overwrite: true });
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One nice little take on .filter((v) => v) is .filter(Boolean) instead. It's a little more explicit and concise. But if you prefer this syntax, don't bother changing. Just throwing that out there.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow cool thing I didn't know that's possible. :)

},

postprocessTree(type, tree) {
if (type === 'all') {
const favicons = new Favicons(tree, this.options);
tree = mergeTrees([ favicons, tree ], { overwrite: true });
return replace(tree, {
files: [ 'index.html' ],
patterns: [{
Expand All @@ -37,7 +47,7 @@ module.exports = {
}]
});
}

return tree;
}

};
Loading