Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why the dryRun command is used in angular?

Tags:

angular

Why dryRun command in Angular CLI is used? Actually, it is mentioned "Run through without making any changes" when i give help command what is the meaning of that sentence.

like image 446
BMSNagaSai chunduru Avatar asked Jul 29 '19 07:07

BMSNagaSai chunduru


People also ask

What is ng serve o?

ng serve is a great command to use when developing your application locally. It starts up a local development server, which will serve your application while you are developing it. It is not meant to be used for a production environment.

What is Ng command?

The ng new command creates an Angular workspace folder and generates a new application skeleton. A workspace can contain multiple applications and libraries. The initial application created by the ng new command is at the top level of the workspace.


2 Answers

It does exactly what you stated.

"Run through without making any changes"

The command will stop the CLI from making any changes to the file system. So if you are unsure about what some command does, you can test it with --dry-run and not worry it will break something in your application.

Here is the real example of how it's used:

ng g component test-component --dry-run

CREATE src/app/components/test-component/test-component.component.html (29 bytes)
CREATE src/app/components/test-component/test-component.component.spec.ts (678 bytes)
CREATE src/app/components/test-component/test-component.component.ts (301 bytes)
CREATE src/app/components/test-component/test-component.component.scss (0 bytes)
UPDATE src/app/app.module.ts (3181 bytes)

NOTE: The "dryRun" flag means no changes were made.

As you can see I've ran a command which generates a new component. How ever since I added a --dry-run flag to it, it only gave me the output of what would happen if I ran that command without --dry-run. My test-component was not actually created in my project. The last line of the output pretty much explains everything:

NOTE: The "dryRun" flag means no changes were made.

like image 160
Dino Avatar answered Sep 30 '22 12:09

Dino


You have to append --dry-run with angular cli commands.

Ex - ng new sample --dry-run

 ng new example --dry-

Simply it just shows (in your cli) what a command does, before it actually does something. It will stop the CLI from making any changes to the file system and it prints everything it would do to your project when you run the command.

like image 22
Dushan Avatar answered Sep 30 '22 11:09

Dushan