Skip to content

Commit

Permalink
Merge pull request #24 from kaliber5/fix-roouter
Browse files Browse the repository at this point in the history
Fix adding not-found route
  • Loading branch information
simonihmig authored Aug 5, 2020
2 parents cbfa9fd + 54ecea8 commit bece38c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
10 changes: 6 additions & 4 deletions blueprints/@kaliber5/k5-ember-boilerplate/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use strict';

const fs = require('fs');
const EmberRouterGenerator = require('ember-router-generator');

module.exports = {
description: 'A boilerplate for Ember apps, tailored for use in kaliber5',
Expand Down Expand Up @@ -133,11 +134,12 @@ module.exports = {
},

async _modifyRouter() {
const route = " this.route('not-found', { path: '/*wildcard' });";
const routerPath = 'app/router.js';
const source = fs.readFileSync(routerPath, 'utf-8');
const routes = new EmberRouterGenerator(source);
const newRoutes = routes.add('not-found', { path: '/*wildcard' });

await this.insertIntoFile('app/router.js', route, {
after: 'Router.map(function () {\n',
});
fs.writeFileSync(routerPath, newRoutes.code());

this.ui.writeLine('Added not-found route to app/router.js');
},
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@
"test:ember-compatibility": "ember try:each",
"blueprint:fix": "prettier --config 'blueprints/@kaliber5/k5-ember-boilerplate/files/.prettierrc.yml' --write 'blueprints/**/*.(js|ts)'"
},
"dependencies": {},
"dependencies": {
"ember-router-generator": "^2.0.0"
},
"devDependencies": {
"@ember/optional-features": "^1.3.0",
"@glimmer/component": "^1.0.0",
Expand Down

0 comments on commit bece38c

Please sign in to comment.