-
Notifications
You must be signed in to change notification settings - Fork 12k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(module): select module to add generations to for declaration
Note: this also displays a warning stating that services are not provided by default
- Loading branch information
Showing
7 changed files
with
83 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 2 additions & 7 deletions
9
addon/ng2/blueprints/module/files/__path__/__name__.module.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,10 @@ | ||
import { NgModule } from '@angular/core'; | ||
import { CommonModule } from '@angular/common'; | ||
import { routing } from './<%= dasherizedModuleName %>.routes'; | ||
import { <%= classifiedModuleName %>Component } from './<%= dasherizedModuleName %>.component'; | ||
|
||
@NgModule({ | ||
imports: [ | ||
CommonModule, | ||
routing | ||
CommonModule | ||
], | ||
declarations: [ | ||
<%= classifiedModuleName %>Component | ||
] | ||
declarations: [] | ||
}) | ||
export class <%= classifiedModuleName %>Module { } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import * as fs from 'fs'; | ||
import * as path from 'path'; | ||
const SilentError = require('silent-error'); | ||
|
||
export function findParentModule( | ||
project: any, | ||
currentDir: string): string { | ||
|
||
const sourceRoot = path.join(project.root, project.ngConfig.apps[0].root, 'app'); | ||
|
||
// trim currentDir | ||
currentDir = currentDir.replace(path.join(project.ngConfig.apps[0].root, 'app'), ''); | ||
|
||
let pathToCheck = path.join(sourceRoot, currentDir); | ||
|
||
while (pathToCheck.length >= sourceRoot.length) { | ||
// let files: string[] = fs.readdirSync(pathToCheck); | ||
|
||
// files = files.filter(file => file.indexOf('.module.ts') > 0); | ||
const files = fs.readdirSync(pathToCheck) | ||
.filter(fileName => fileName.endsWith('.module.ts')) | ||
.filter(fileName => fs.statSync(fileName).isFile()); | ||
|
||
if (files.length === 1) { | ||
return path.join(pathToCheck, files[0]); | ||
} else if (files.length > 1) { | ||
throw new SilentError(`Multiple module files found: ${pathToCheck.replace(sourceRoot, '')}`); | ||
} | ||
|
||
// move to parent directory | ||
pathToCheck = path.resolve(path.join(pathToCheck, '..')); | ||
} | ||
|
||
throw new SilentError('No module files found'); | ||
} |