File tree Expand file tree Collapse file tree 1 file changed +4
-2
lines changed
packages/schematics/angular/utility Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Original file line number Diff line number Diff line change 99import { tags } from '@angular-devkit/core' ;
1010import * as ts from '../third_party/github.com/Microsoft/TypeScript/lib/typescript' ;
1111import { Change , InsertChange , NoopChange } from './change' ;
12+ import { getEOL } from './eol' ;
1213
1314/**
1415 * Add Import `import { symbolName } from fileName` if the import doesn't exit
@@ -73,12 +74,13 @@ export function insertImport(
7374 }
7475 const open = isDefault ? '' : '{ ' ;
7576 const close = isDefault ? '' : ' }' ;
77+ const eol = getEOL ( rootNode . getText ( ) ) ;
7678 // if there are no imports or 'use strict' statement, insert import at beginning of file
7779 const insertAtBeginning = allImports . length === 0 && useStrict . length === 0 ;
78- const separator = insertAtBeginning ? '' : ';\n' ;
80+ const separator = insertAtBeginning ? '' : `; ${ eol } ` ;
7981 const toInsert =
8082 `${ separator } import ${ open } ${ importExpression } ${ close } ` +
81- ` from '${ fileName } '${ insertAtBeginning ? ';\n' : '' } ` ;
83+ ` from '${ fileName } '${ insertAtBeginning ? `; ${ eol } ` : '' } ` ;
8284
8385 return insertAfterLastOccurrence (
8486 allImports ,
You can’t perform that action at this time.
0 commit comments