Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

User-defined resources for the --watch option #80

Closed
wants to merge 5 commits into
from

Conversation

Projects
None yet
4 participants

This will allow compilation of files other than .js, .css, and .json files using the shifter --watch command. Basically, I want to watch for any changes in LESS files so that the a module's CSS is updated automatically.

This command will commonly be used in conjunction with the "exec" option in a module's build.json.

An example build.json:

{
    "name": "module",
    "exec": [
        "less-compile"
    ],
    "builds": {
        "module": {
            "jsfiles": ["module.js"],
            "skinnable": true
        }
    }
}

How to use:

This can be added to the .shifter.json file:

{
    "watched-extensions" : {
        ".less": true,
        ".js": true,
        ".json": true
    }
}
or alternatively,

shifter --watch js --watch less --watch json

Known issues:

Currently, CSS and LESS files cannot be watched together else shifter will indicate that the CSS file has been changed too quickly. This is why the previous example does not watch CSS, only LESS.

Contributor

derek commented May 10, 2013

Nice idea.

I'd prefer to see --watch accept a String as opposed to a Boolean, it seems redundant to specify --watch and --watched-type together as the latter implies the first should be true.

Also, IMO it also seems unnatural to specify an escaped JSON string in the CLI arguments, so I'd rather see additional --watch arguments for each extension, and nopt will turn it into an array when it parses the arguments list.

For example...

Defaults to watching .css, .js, and .json

--watch 

Ignores defaults, only watches .less

--watch less

Ignores defaults, watches .less and .js

--watch less --watch js

This way, you don't have to specify which extensions you don't want to watch, just the ones you do. I guess it would be possible to add in support for --no-watch, but that seems unnecessary at the moment.

Under the hood in the .shifter.json config, getting picky I'd prefer watched-extensions, but otherwise the implementation seems sound.

Contributor

evocateur commented May 11, 2013

I concur with @derek's comments. nopt is full of win.

Bret Ikehara and others added some commits May 3, 2013

@bretkikehara Bret Ikehara Added the code to allow a user to define a watched resource in the .s…
…hifter.json file.

Added the watched-types configuration.
c5cdff3
@bretkikehara Bret Ikehara Fixed test for getKey type normalization function. 1b0915c
@bretkikehara @bretkikehara bretkikehara Changed watched-types to watched-extensions.
Allows for --watch multiple time instead of an object as an argument.
0672439
@bretkikehara Bret Ikehara Cleaned up watched extensions tests wording and variable names. a0b8136
@bretkikehara bretkikehara Expanded upon the tests for watched-extensions.
Changed the 'watched-extensions' global config to array instead of object.
Updated version of cssproc dependecy to 0.0.3
b61073c
Owner

caridy commented Jun 9, 2014

Yogi does the watching, closing this.

@caridy caridy closed this Jun 9, 2014

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