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
Add the path to the WebStorm bin folder to the Path
environment variable (for example, C:\Program Files\JetBrains\WebStorm\bin).
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.
Opening files, folders, and projects
At the command prompt, type:
<WebStorm> pathFor 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.
Learn more from Code inspections.
To launch a code inspection from the command line
Exit WebStorm otherwise the
inspect
fails.At the command prompt, type:
<WebStorm> inspect project-path inspection-path output-path [-vX] [-d subdirectory-path]where <WebStorm> is the platform-specific launcher.
To view the results of an offline inspection
Open the project against which you ran the inspection.
From the main menu, choose
.In the Select Path dialog 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 |
---|---|
project-path | The full path to the directory that contains the project to be inspected. |
inspection-path | 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:
|
output-path | The full path to an existing directory where the XML file with the inspection report will be stored. |
-vX | (optional) The verbosity level of the output, where |
-d subdirectory-path | (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:
<WebStorm> diff path1 path2
where <WebStorm> is the platform-specific launcher, path1
and path2
are the full paths to the files to compare. WebStorm opens the files in the Differences viewer for files.
Learn more from Comparing files, folders and text sources.
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:
<WebStorm> merge path1 path2 path3 outputwhere <WebStorm> is the platform-specific launcher,
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