我的笔记是由vscode的devcontainer编写的,它是sphinx。所以当任何.rst文件改变时,我想添加sphinx-autobuild来自动构建我的笔记。
这个命令是sphinx-autobuild /workspaces/notes /workspaces/notes/_build/html/。
我在Dockerfile中附加了CMD sphinx-autobuild /workspaces/notes /workspaces/notes/_build/html/,它不能很清楚地工作。
如何在devcontainer打开后自动运行此cmd?
发布于 2021-08-06 02:50:01
最后,我找到了答案。
根据devcontainerjson-reference的说法,在创建、启动或附加容器时,可以使用postCreateCommand、postStartCommand和postAttachCommand来运行命令。
因此,要在打开vscode之后运行sphinx-autobuild,只需追加
"postAttachCommand": "sphinx-autobuild /workspaces/notes/ /workspaces/notes/_build/html/",敬devcontainer.json。
postAttachCommand是字符串或数组的类型。
https://stackoverflow.com/questions/68646002
复制相似问题