Skip to content

Commit d999119

Browse files
authored
Schematics/fix dasherize spaces name (#21)
* schematics(fix): fix problems pre alpha for support scully.config.js * schematics(fix): rename flag for post, for support schematics names\ * schematics(post): add support for name with spaces * schematics(fix): fix inject into scully.config.js for support space in the name * schematics(fix): fix dasherize from folder and md name
1 parent bbca707 commit d999119

File tree

5 files changed

+8
-6
lines changed

5 files changed

+8
-6
lines changed

schematics/scully/package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

schematics/scully/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@scullyio/init",
3-
"version": "0.0.4",
3+
"version": "0.0.5",
44
"description": "Add scully to your angular app",
55
"repository": {
66
"type": "GIT",
382 KB
Binary file not shown.

schematics/scully/src/create-markdown/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@ export default function(options: MyServiceSchema): Rule {
88
try {
99
options.name = options.name ? options.name : 'blog';
1010
const name = options.name;
11+
const nameD = strings.dasherize(options.name);
1112
const date = new Date();
1213
const fullDay = `${date.getMonth() + 1}-${date.getDate()}-${date.getFullYear()}`;
13-
const path = `./${name}/${fullDay}-${name}.md`;
14+
const path = `./${nameD}/${fullDay}-${nameD}.md`;
1415
if (!host.exists(path)) {
1516
host.create(path, `---
1617
title: This is the ${name}
@@ -20,7 +21,7 @@ publish: false
2021
2122
# Page ${name} example
2223
`);
23-
context.logger.info(`✅ ${fullDay}-${name} file created`);
24+
context.logger.info(`✅ ${fullDay}-${nameD} file created`);
2425
}
2526

2627
let scullyJson;

schematics/scully/src/utils/utils.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import {apply, forEach, mergeWith, Rule, SchematicContext, Source, Tree} from '@angular-devkit/schematics';
2+
import {strings} from '@angular-devkit/core';
23

34
interface Data {
45
name: string;
@@ -7,10 +8,10 @@ interface Data {
78
}
89

910
export function addRouteToScullyConfig(scullyConfigJs: string, data: Data) {
10-
const addRoute = `\n '/${data.name}/:${data.slug}': {
11+
const addRoute = `\n '/${strings.dasherize(data.name)}/:${data.slug}': {
1112
type: '${data.type}',
1213
${data.slug}: {
13-
folder: "./${data.name}"
14+
folder: "./${strings.dasherize(data.name)}"
1415
}
1516
},`;
1617
let output;

0 commit comments

Comments
 (0)