Provide a filename-only placeholder for exec #100

Open
wants to merge 2 commits into
from

3 participants

@cawoodm

Say we want to run unit-tests when the current file foo.js is saved. Our tests require that the following command is run:
node tests\test-foo.js

In order for this to work we need a ${filename} placeholder which returns only foo.js and not the full path (as ${file} currently does).

"exec": {
  "afterSave": {
    "*.js": "node tests/test-${filename}"
  }
}
@cawoodm cawoodm Provide a filename-only placeholder for exec
Say we want to run unit-tests when the current file `foo.js` is saved. Our tests require that the following command is run:
`node tests\test-foo.js`

In order for this to work we need a `${filename}` placeholder which returns only `foo.js` and not the full path (as `${file}` currently does).

```javascript
  "exec": {
    "afterSave": {
      "*.js": "node tests/test-${filename}.js"
    }
  }
```
5583394
@cawoodm

Trust me - it's awesome:
tests

@aeisenberg

Thanks for the Christmas present!

@cawoodm

Ho ho ho!

I have an update/addition. If you run exec in a subfolder (foo/) it seems to remain in the projectDir so you need the subpath foo/db.js.

Should we adapt my code above or add a new ${filenamer} (filename __r__elative):

def("${filenamer}", function() {
    var p = editor.getFilePath();
    return p.substring((window.fsroot || getDir()).length+1);
});
@aeisenberg
@cawoodm cawoodm Renamed ${fileName}. Added ${fileBase} ${filePath}
Renamed ${filename} to ${fileName}
Added ${fileBase} and ${filePath}
dfbbd33
@cawoodm

OK, I went with:
$fileName -> hello.js
$fileBase -> hello
$filePath -> subdir/hello.js

@cawoodm

@aeisenberg can you merge my cawoodm@dfbbd33 changes?

@aclement

Marc - I'm afraid we are still waiting for a contributor agreement to be setup so that you can sign it and we can take the contribution. I'm really hoping it'll be in the next few days.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment