Working with WebStorm Features from Command Line
With WebStorm, you can open, format, inspect, compare, and merge files from the command line.
Enabling a command-line launcher
For Windows
Add the path to the WebStorm
bin
folder to thePath
environment variable (for example,C:\Program Files\JetBrains\WebStorm\bin
).
For macOS and Linux
On macOS and Linux, create the command-line launcher to integrate WebStorm with your shell. Ensure that the created launcher script is within the search path of your shell so that it can be invoked system-wide.
From the main menu, select
.In the Create Launcher Script dialog that opens, type the name of the launcher and the path to it, or accept the suggested default value webstorm.
Outside WebStorm, add the path and the name of the launcher script to your
path
.
Launching WebStorm
At the command prompt, type the
<WebStorm>
command and press Enter.<WebStorm>
is the platform-specific launcher.
webstorm.exe
webstorm
Opening files, folders, and projects
At the command prompt, type:
<WebStorm> path
For files, optionally specify the line where the cursor should be placed using one of the following formats:
<WebStorm> [--line <number>] path <WebStorm> path:<number>
If the file or folder belongs to an existing project, this project will be opened.
If the file does not belong to any project, a temporary project for this file will be created automatically.
If the folder does not belong to any project, a new project will be created inside this folder.
Examples
- Syntax
-
webstorm.exe --line <number> path
- Alternative syntax
-
webstorm.exe path:<number>
- Examples
-
webstorm.exe --line 3 C:\MyProject\scripts\numbers.js webstorm.exe C:\MyProject\scripts\numbers.js:3
- Syntax
-
webstorm --line <number> path
- Alternative syntax
-
webstorm path:<number>
- Example
-
webstorm --line 3 ~/MyProject/scripts/numbers.js webstorm ~/MyProject/scripts/numbers.js:3
Running code inspections
In addition to running code inspections from the main menu or from the context menus of the Project Tool Window, you can also launch the inspector from the command line, without actually running WebStorm.
This way you can perform regular code inspections as a part of your development process, which is especially important for large projects. Inspection results are stored in the XML format, and you can download and view these results at any time.
To launch a code inspection from the command line
Exit WebStorm otherwise the
inspect
fails.At the command prompt, type:
where <WebStorm> is the platform-specific launcher.<WebStorm> inspect project-path inspection-path output-path [-vX] [-d subdirectory-path]
To view the results of an offline inspection
Open the project agains which you ran the inspection.
On the main menu, choose
.In the Select Path dialog box that opens, click the directory where the XML file with the inspection results is stored.
Click OK. The Inspection results are displayed in the Offline View tab in the Inspection Results Tool Window.
Command-line options
Option | Description |
---|---|
| The full path to the directory that contains the project to be inspected. |
| The full path to the inspection profile against which the project is to be inspected. By default, inspection profiles are stored under the following directory:
|
| The full path to an existing directory where the XML file with the inspection report will be stored. |
| (optional) The verbosity level of the output, where |
| (optional) The full path to the subdirectory to be inspected. |
Examples
- Syntax
-
webstorm.exe inspect project-path inspection-path output-path -v2 -d subdirectory-path
- Example
-
webstorm.exe inspect E:\MyProject E:\MyProject\.idea\inspectionProfiles\Project_Default.xml E:\MyProject\inspection-results-dir -v2 -d E:\MyProject\subdirectory
- Syntax
-
webstorm inspect project-path inspection-path output-path -v2 -d subdirectory-path
- Example
-
webstorm inspect ~/MyProject ~/MyProject/.idea/inspectionProfiles/Project_Default.xml ~/MyProject/inspection-results-dir -v2 -d ~/MyProject/subdirectory
- Syntax
-
webstorm inspect project-path inspection-path output-path -v2 -d subdirectory-path
- Example
-
webstorm inspect ~/MyProject ~/MyProject/.idea/inspectionProfiles/Project_Default.xml ~/MyProject/inspection-results-dir -v2 -d ~/MyProject/subdirectory
Comparing files
At the command prompt, type:
where <WebStorm> is the platform-specific launcher,<WebStorm> diff path1 path2
path1
andpath2
are the full paths to the files to compare. WebStorm opens the files in the Differences Viewer for Files.
Examples
- Syntax
-
webstorm.exe diff path1 path2
- Example
-
webstorm.exe diff C:\MyProject\Readme.md C:\MyProject\Readme.md.bak
- Syntax
-
webstorm diff path1 path2
- Example
-
webstorm diff ~/MyProject/Readme.md ~/MyProject/Readme.md.bak
Merging files
At the command prompt, type:
where <WebStorm> is the platform-specific launcher,<WebStorm> merge path1 path2 path3 output
path1
andpath2
are the full paths to the files to merge,path3
is optional and points at the base revision from which the files diverges, andoutput
is the path to the file where the results of merging will be stored.In the Merge dialog that opens, explore the changes and accept or discard each of them one by one as described in Resolving Conflicts.
Examples
- Syntax
-
webstorm.exe merge path1 path2 path3 output
- Example
-
webstorm.exe merge C:\MyProject\Readme.md.bak C:\MyProject\Readme.md C:\Archive\Readme.md C:\NewProject\Readme.md
- Syntax
-
webstorm merge path1 path2 path3 output
- Example
-
webstorm merge ~/MyProject/Readme.md.bak ~/MyProject/Readme.md ~/Archive/Readme.md ~/NewProject/Readme.md