Skip to content

Commit

Permalink
fix(@angular/cli): add error message when missing config env variable (
Browse files Browse the repository at this point in the history
…#5980)

I tried to implement a continuous integration system on my VPS. I have a PHP script that runs ng build. However in my default PHP configuration no environment variable HOME or USERPROFILE was set. I had this error : `Path must be a string. Received undefined`.

I had to take some time to see where the problem came from so I made a pull request to clarify the error.

Now it is : `Error: Missing environment variable HOME` which does not require to look at the code. This message would have saved me some time.
  • Loading branch information
victorboissiere authored and filipesilva committed May 4, 2017
1 parent 5066c46 commit 11d0afc
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/@angular/cli/models/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@ const CLI_CONFIG_FILE_NAME_ALT = 'angular-cli.json';


function getUserHome() {
return process.env[(process.platform.startsWith('win')) ? 'USERPROFILE' : 'HOME'];
const envHomeName = (process.platform.startsWith('win')) ? 'USERPROFILE' : 'HOME';
const env = process.env[envHomeName];
if (env == null) {
throw new Error('Missing environment variable ' + envHomeName);
}
return env;
}


Expand Down

0 comments on commit 11d0afc

Please sign in to comment.