Home Download Buy Blog Forum Support

Build selector question

Build selector question

Postby wraith on Tue Sep 24, 2013 4:44 am

I like the build system for coffeescript, less, etc. but my googlefu failed me when learning how to target a selector by file name instead of extension. Lots of SO answers and example build blog posts assume "selector": "package.json" would work, but they don't (I'm assuming because of the lack of the "source" string). Mainly, the examples half work, in that they set a "working_dir" which operates from the project folder, and ignores the automatic "selector" functionality.

Am I overlooking how to select on a file name?

I'd love to be able to use
Code: Select all
{
   "cmd": [ "node", "$file" ],
   "selector": "app.js"
}

and
Code: Select all
{
   "cmd": [ "npm install" ],
   "selector": "package.json"
}

without accidentally trying to build "other.js" or "random.json"
wraith
 
Posts: 4
Joined: Tue Sep 24, 2013 4:13 am

Re: Build selector question

Postby bizoo on Tue Sep 24, 2013 7:15 am

selector is a scope name. It's not a file name. nor a file extension.

I think there's a plugin somewhere to build based on file extension, but couldn't remember where.
It's probably not something very difficult to write by yourself.

Build system use the scope name where the (first?) caret of the current active view is located.
To find this information, open the console and type the command below, the result here is for a json file:
Code: Select all
>>> view.scope_name(view.sel()[0].a)
u'source.json meta.structure.dictionary.json punctuation.definition.dictionary.begin.json '

Usually we use the global scope name, which is the first part of this string:
Code: Select all
source.json
bizoo
 
Posts: 876
Joined: Wed Dec 08, 2010 6:53 am
Location: Switzerland


Return to Technical Support

Who is online

Users browsing this forum: Exabot [Bot], Yahoo [Bot] and 15 guests