Skip to content

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

Closed
wants to merge 3 commits into from
Closed

Conversation

chgc
Copy link
Contributor

@chgc chgc commented Aug 17, 2016

#1719

Correction path in windows
eg: ./parentCompoent\ChildComponet/ChildComponet

#1719
Correction path in windows
eg: ./parentCompoent\ChildComponet/ChildComponet
@googlebot
Copy link

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!) and we'll verify. Thanks.


  • If you've already signed a CLA, it's possible we don't have your GitHub username or you're using a different email address. Check your existing CLA data and verify that your email is set on your git commits.
  • If you signed the CLA as a corporation, please let us know the company's name.

@chgc
Copy link
Contributor Author

chgc commented Aug 17, 2016

I signed it.

@googlebot
Copy link

CLAs look good, thanks!

@filipesilva
Copy link
Contributor

@hansl can you review? This PR is meant to address #1719

@@ -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
Copy link
Contributor

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.

Copy link
Contributor Author

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

Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

  1. 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())); }

  2. 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

@chgc chgc closed this Sep 2, 2016
@chgc
Copy link
Contributor Author

chgc commented Sep 2, 2016

Closed this pull request due to ast-utils has been move to separate package.
this bug remains.

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 10, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants