WebStorm 2018.2 Help

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 the Path 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.

  1. From the main menu, select Tools | Create Command-line Launcher.

  2. 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.

  3. 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

  1. Exit WebStorm otherwise the inspect fails.

  2. 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

  1. Open the project agains which you ran the inspection.

  2. On the main menu, choose Code | View Offline Inspection Results.

  3. In the Select Path dialog box that opens, click the directory where the XML file with the inspection results is stored.

  4. 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:
  • Windows: %HOMEPATH%\.2018.2\config\inspection

  • macOS: ~/Library/Preferences/2018.2/inspection

  • Linux: ~/.2018.2/config/inspection

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 X is 0 for quiet, 1 – for noisy, and 2 – for extra noisy.

-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.

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

  1. At the command prompt, type:

    <WebStorm> merge path1 path2 path3 output
    where <WebStorm> is the platform-specific launcher, path1 and path2 are the full paths to the files to merge, path3 is optional and points at the base revision from which the files diverges, and output is the path to the file where the results of merging will be stored.

  2. 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
Last modified: 2 October 2018

See Also