Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Provide a filename-only placeholder for exec #100

Open
wants to merge 2 commits into from

3 participants

Marc Andrew Eisenberg Andy Clement
Marc

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}"
  }
}
Marc 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
Marc

Trust me - it's awesome:
tests

Andrew Eisenberg

Thanks for the Christmas present!

Marc

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);
});
Andrew Eisenberg
Marc cawoodm Renamed ${fileName}. Added ${fileBase} ${filePath}
Renamed ${filename} to ${fileName}
Added ${fileBase} and ${filePath}
dfbbd33
Marc

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

Marc

@aeisenberg can you merge my cawoodm@dfbbd33 changes?

Andy Clement
Owner

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
Commits on Dec 25, 2012
  1. Marc

    Provide a filename-only placeholder for exec

    cawoodm authored
    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"
        }
      }
    ```
Commits on Dec 30, 2012
  1. Marc

    Renamed ${fileName}. Added ${fileBase} ${filePath}

    cawoodm authored
    Renamed ${filename} to ${fileName}
    Added ${fileBase} and ${filePath}
This page is out of date. Refresh to see the latest.
Showing with 19 additions and 0 deletions.
  1. +19 −0 client/scripts/scripted/exec/param-resolver.js
19 client/scripts/scripted/exec/param-resolver.js
View
@@ -83,6 +83,25 @@ function forEditor(editor) {
return editor.getFilePath();
});
+ // Returns 'hello.js' from '/path/project/sub/helloworld.js'
+ def("${fileName}", function() {
+ var p = editor.getFilePath();
+ return p.substring(p.lastIndexOf('/')+1);
+ });
+
+ // Returns 'sub/hello.js' from '/path/project/sub/helloworld.js'
+ def("${filePath}", function() {
+ var p = editor.getFilePath();
+ return p.substring((window.fsroot || getDir()).length+1);
+ });
+
+ // Returns 'hello' from '/path/project/sub/helloworld.js'
+ def("${fileBase}", function() {
+ var p = editor.getFilePath();
+ p = p.substring(p.lastIndexOf('/')+1);
+ return p.substring(0, p.lastIndexOf('.'));
+ });
+
def("${dir}", getDir);
def("${projectDir}", function () {
Something went wrong with that request. Please try again.