是否可以在.watchmanconfig中配置Watchman触发器? [英] Is it possible to configure watchman triggers in .watchmanconfig?

查看:186
本文介绍了是否可以在.watchmanconfig中配置Watchman触发器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Facebook守望者文档描述了如何通过将json传递到命令中来配置触发器,如下所示:

Facebook watchman docs describe how to configure triggers by passing json into the command like so:

watchman --json-command<./tasks/cmds/watchman-build-trigger.json watchman-build-trigger.json包含以下内容:

watchman --json-command < ./tasks/cmds/watchman-build-trigger.json where watchman-build-trigger.json contains the following:

[
    "trigger", 
    "/Users/michaelprescott/Projects/neuro", 
    {
        "name": "build",
        "expression": [
            "anyof",
            [
                "match",
                "src/*.js",
                "wholename"
            ],
            [
                "match",
                "src/*.ts",
                "wholename"
            ],
            [
                "match",
                "src/*.html",
                "wholename"
            ]
        ],
        "command": [
            "./tasks/cmds/build.sh"
        ]
    }
]

但是,我试图了解如何使用.watchmanconfig通过 watchman watch-project 设置手表和触发器集我有以下内容,但未创建触发器.这可能吗?有没有人有.watchmanconfig的示例

However, I'm trying to understand how to use .watchmanconfig to setup a watch and set of triggers with watchman watch-project I have the following, but triggers aren't created. Is this possible? Does anyone have examples for .watchmanconfig's

{
    "ignore_dirs": [
        "node_modules"
    ],
    "watched": [
        {
            "path": "/Users/michaelprescott/Projects/neuro",
            "triggers": [
                {
                    "command": [
                        "./tasks/cmds/build.sh"
                    ],
                    "expression": [
                        "anyof",
                        [
                            "match",
                            "src/*.js",
                            "wholename"
                        ],
                        [
                            "match",
                            "src/*.ts",
                            "wholename"
                        ],
                        [
                            "match",
                            "src/*.html",
                            "wholename"
                        ]
                    ],
                    "name": "build"
                }
            ]
        }
    ]
}

推荐答案

否,无法通过 .watchmanconfig 进行.理由是,由于 .watchmanconfig 旨在被检查到可以被任意人克隆的存储库中,因此我们宁愿不允许它成为可以在不运行任意代码的情况下运行的工具那些人明确采取行动来运行它.

No, it's not possible via .watchmanconfig. The rationale is that, since .watchmanconfig is intended to be checked into a repo that may be cloned by arbitrary folks, we'd rather not allow it to be a vehicle by which arbitrary code could be run without those people explicitly taking an action to run it.

我们的建议是将触发器的创建包装在某种类型的脚本中,当用户希望启用触发行为时,可以指导用户运行该脚本.

Our recommendation is to wrap up the trigger creation in a script of some kind that you can direct users to run when they would like to enable the triggering behavior.

此外,我敦促您改为查看 watchman-make ;它具有比触发器更好的人体工程学设计,因为它很容易看到正在运行的命令的输出,并在希望它们停止时将其终止.

In addition, I'd urge you to instead take a look at watchman-make for this use case; it has nicer ergonomics than triggers because it is very much easier to see the output from the commands that are being run and to terminate them when you want them to stop.

例如,您可以改为通过以下方式实现触发器:

For example, you could implement your trigger this way instead:

watchman-make -r任务/cmds/build.sh -p'src/*.js'-p'src/*.ts'-p'src/*.html'

(单引号很重要!)

这篇关于是否可以在.watchmanconfig中配置Watchman触发器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆