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

fix(schematics): add parse5 dep #11647

Merged
merged 4 commits into from
Jun 28, 2018
Merged
Show file tree
Hide file tree
Changes from 3 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
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@
"tslib": "^1.9.0",
"zone.js": "^0.8.26"
},
"optionalDependencies": {
"parse5": "^5.0.0"
},
"devDependencies": {
"@angular-devkit/core": "^0.5.12",
"@angular-devkit/schematics": "^0.5.12",
Expand Down
4 changes: 4 additions & 0 deletions src/lib/schematics/utils/html.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ import {Project} from './devkit-utils/config';
* @param src the src path of the html file to parse
*/
export function getHeadTag(host: Tree, src: string) {
if (!parse5) {
Copy link
Member

Choose a reason for hiding this comment

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

Should this check be earlier? I want to make sure that we don't partially run the schematic before bailing out here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

throw new SchematicsException('parse5 depedency not found! Please install parse5 from npm to continue.');
}

const document = parse5.parse(src,
{locationInfo: true}) as parse5.AST.Default.Document;

Expand Down