-
Notifications
You must be signed in to change notification settings - Fork 12k
correction sub-component path in windows when import to ngModule #1719 #1736
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
Conversation
#1719 Correction path in windows eg: ./parentCompoent\ChildComponet/ChildComponet
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed, please reply here (e.g.
|
I signed it. |
CLAs look good, thanks! |
@@ -70,6 +70,9 @@ export function bootstrapItem(mainFile, imports: {[key: string]: [string, boolea | |||
|
|||
export function insertImport(fileToEdit: string, symbolName: string, | |||
fileName: string, isDefault = false): Change { | |||
|
|||
fileName = fileName.replace(/\\/, '/'); // correction in windows |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use path.posix.normalize()
instead of replace. Thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hi, hansl.
I tried to use path.posix.normalize() . but the result wasn't correct. the Result is shown as below.
before normalize. fileName is './aa\bb/bb.component'
after normalize fileName is 'aa\bb/bb.component'
I couldn't find the reason why this didn't work. my node version is 6.3.1.
A little more help, please. Thanks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This probably means that the generation of the './aa\bb/bb.component'
path is the real issue. Check invocation of insertImport
and see how the third argument fileName
is being composed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-
start from blueprint/component/index.js line: 120
const componentDir = path.relative(this.dynamicPath.appRoot, this.generatePath); const importPath = componentDir ?
./${componentDir}/${fileName}:
./${fileName}; if (!options['skip-import']) { returns.push( astUtils.addComponentToModule(modulePath, className, importPath) .then(change => change.apply())); }
-
ast-utils.js line: 291
export function addComponentToModule(modulePath: string, classifiedName: string, importPath: string): Promise<Change> { return _addSymbolToNgModuleMetadata(modulePath, 'declarations', classifiedName, importPath); }
3.in file: ast-utils. _addSymbolToNgModuleMetadata line: 282
const importInsert: Change = insertImport(ngModulePath, symbolName, importPath);
the importPath is carried through from the beginning.(blueprint/component and others).
It seems componentDir is wrong. path.relative(windows environment) will use '' to return relative path.
By the way. in route-utils.ts line:205. I used the same trick to fix #1719
Closed this pull request due to ast-utils has been move to separate package. |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
#1719
Correction path in windows
eg: ./parentCompoent\ChildComponet/ChildComponet