Skip to content

Running Gulp (or anything) from the command line on a dnx project.json command execution? #451

@guardrex

Description

@guardrex

I'm working with Brackets and Gulp prior to CTP7 hitting. I have a command setup to use WebListener:

"commands": {
        "test": "Microsoft.AspNet.Hosting --server Microsoft.AspNet.Server.WebListener --server.urls http://localhost:5001"
},

I would like to have my gulpfile.js run whenever I execute my test command. Because I'm using Brackets right now, I can't use VS's nice build events feature to run Gulp automatically.

I am aware of the existence of gulp.task('watch', function () { ... }, but I would prefer not to have to type gulp even once before executing dnx . test. I want Gulp to run automatically once each time I issue my dnx . test command.

I tried hooking it by way of the scripts of project.json by simply replacing the echo xxx line with the command gulp:

"scripts": {
        "prepack": "echo before packing",
        "postpack": "echo after packing",
        "prepublish": "echo before publishing",
        "postpublish": "echo after publishing",
        "prerestore": "echo before restoring packages",
        "postrestore": "echo after restoring packages",
        "prepare": "echo prepare"
},

... but nothing will trigger Gulp prior to firing up WebListener. prerestore and postrestore will run Gulp when I use dnu restore, but I may as well be typing gulp at the command line once (using a gulp watch task) before running dnx . test rather than using dnu restore every time, since I usually do not need to restore packages to test run my app.

Can it be done?

If not, I'd like to float a feature request for one more scripts option for something like precommand, which could be a command line statement to be run when any dnx . {command} is issued? This could have a variety of uses well beyond just a simple Gulp call. It would be even better if you could attach command line commands to any of your dnx commands (e.g., "precommand": [{"test": "gulp"}, {"another dnx command": "another command line command"}]).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions