angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

Different parsing of --bh attribute on windows and unix OS

Open ptsydzik-zz opened this issue 9 years ago • 9 comments

Please provide us with the following information:

OS?

Windows 7, 8 or 10. Linux (which distribution). Mac OSX (Yosemite? El Capitan?)

Versions.

angular-cli: 1.0.0-beta.24 node: 5.11.1 os: darwin x64 @angular/common: 2.4.1 @angular/compiler: 2.4.1 @angular/core: 2.4.1 @angular/forms: 2.4.1 @angular/http: 2.4.1 @angular/platform-browser: 2.4.1 @angular/platform-browser-dynamic: 2.4.1 @angular/router: 3.4.1 @angular/compiler-cli: 2.4.1

Repro steps.

update package.json to have "build": "ng build --bh '${rootContext}/' --environment=prod --target=production", line in script section

this will have correct output in index.html on Linux/OSX <base href="${rootContext}/"> but on windows its will be <base href="'${rootContext}/'"> if change package.json to have "build": "ng build --bh \"${rootContext}\/" --environment=prod --target=production", we will got correct otput on Windows but on Linux/OSX it will be <base href="">. if package.json to have line like this "build": "ng build --bh ${rootContext}/ --environment=prod --target=production",, output will be invalid on both OS.

Note:

${rootContext} - is a var that will be replaced by java backend on server then return index.html to user.

Question

How to make it works on any OS?

ptsydzik-zz avatar Jan 13 '17 06:01 ptsydzik-zz

This sounds like a bug with how we parse the argument. Will need to investigate.

filipesilva avatar Jan 13 '17 12:01 filipesilva

Windows 8.1, git-bash: Command: ng build --base-href /foo/ Result: <base href="C:/Program Files/Git/foo/">

v-sul avatar Feb 02 '17 09:02 v-sul

@filipesilva, any updates on this?

ptsydzik-zz avatar Feb 16 '17 14:02 ptsydzik-zz

@s1im05 that happens in git bash because it parses arguments in a certain way - /foo/ really is C:/Program Files/Git/foo/.

@ptsydzik I had a quick look now and as far as I can tell the variables we get inside the CLI are 'correct'. What's happening is that Windows/Linux/OSX interpret quotes differently in npm scripts.

For npm scripts to work correctly with string args in Windows, they really need to be surrounded by \". That seems to not work so well with the ${var} notation in Bash though.

Not sure what we can do on the CLI side, the value we get is already the one interpreted by the terminal.

filipesilva avatar Feb 16 '17 16:02 filipesilva

Maybe implement reading options from config file can help? e.g. ng build --build-config build.config.json

and in build.config.json do:

{ "baseHref": "\'${rootContext}\/\'", "environment": "prod", "target": "production", ..... }

ptsydzik-zz avatar Feb 17 '17 07:02 ptsydzik-zz

Thanks for reporting this issue. This issue is now obsolete due to changes in the recent releases. Please update to the most recent Angular CLI version.

If the problem persists after upgrading, please open a new issue, provide a simple repository reproducing the problem, and describe the difference between the expected and current behavior.

filipesilva avatar May 22 '17 15:05 filipesilva

Still getting this issue with CLI v1.1.1

@filipesilva which v. of the CLI should this be fixed in?

Steps to reproduce, git bash Win 10: $ ng new foo --style scss --routing --prefix foo $ cd foo/ && ng build --prod --base-href=/something/here/

index.html shows <base href="C:/Program Files/Git/something/here/">

danwulff avatar Jun 09 '17 00:06 danwulff

@danwulff what you're experiencing is https://github.com/angular/angular-cli/issues/5606.

filipesilva avatar Jun 12 '17 10:06 filipesilva

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.