Reputation: 452
I have a lot of scripts I want to run / debug from Webstorm, but for each I have to go thru the process of "Run > Edit Configurations" and add a new configuration mapped to each file.
Is there a variable / shortcut to tell WebStorm to run / debug currently opened file?
Something like ${opened-file}
would be great to have a Run Configuration "template".
Thanks.
Upvotes: 22
Views: 4236
Reputation: 4452
Application parameters
has a macros support (plus icon in the field). You need to use $FilePathRelativeToProjectRoot$
macros.
This example runs node /node_modules/.bin/wdio wdio.local.conf.js --spec foo.js
. foo.js
is $FilePathRelativeToProjectRoot$
Upvotes: 6
Reputation: 478
You can do 'Run context configuration' to execute the current open file. The default shortcut should be control+shift+R on Mac.
Upvotes: 2
Reputation: 7981
One way to do this is right clicking the file, then choosing Run <filename>
. This will run the current file using the defaults from the Run Configuration.
Upvotes: 1
Reputation: 2796
I appreciate the pain you're feeling. I have a similar desire. However, there may be a way to accomplish what you're trying to do without it.
I'm using Webstorm + Jasmine for node development. Here are the steps I followed to get a working TDD setup:
{
"spec_dir": "src/test",
"spec_files": [ "**/*[sS]pec.js" ]
}
describe('HelloWorld', function () {
const HelloWorld = require('../HelloWorld');
describe('#greeting', function() {
it('should be friendly', function() {
expect(new HelloWorld().greeting()).toEqual("Hello, World");
});
});
});
setup run/debug config: default node runner with options:
environment variable: JASMINE_CONFIG_PATH = src/test/jasmine.json (set in step 4 above)
This produces an entry in the .idea/workspace.xml file like this:
<configuration default="true" type="NodeJSConfigurationType" factoryName="Node.js" path-to-node="project" node-parameters="node_modules/jasmine/bin/jasmine.js" working-dir="$PROJECT_DIR$">
<envs>
<env name="JASMINE_CONFIG_PATH" value="src/test/jasmine.json" />
</envs>
</configuration>
Javascript file
option.I've created a pretty fluid workflow with this setup. Considering that ctrl+R will re-run the last run config, you can be writing the test, use ctrl+shift+R to run it, then start writing the code, and use ctrl+R to re-run that same test file.
Upvotes: 0