LoginSignup
4
1

More than 3 years have passed since last update.

VScodeで保存時に任意コマンドを走らせるようにしよう!!

Posted at

はじめに

とある事情で、コードを書いたらReactの手動Buildをするというフローを繰り返しているのですが。めちゃくそ発狂したのでCtrl Sをした時に任意コマンドを実行できたらええのになーーーと思ったので解決に至った。

結論

VScodeの「Run on Save」という拡張機能を使ってええ感じになった。

Step1

VScodeで「Run on Save」を検索してEnable
Screenshot from 2021-02-05 10-32-43.png

Step2

Shift + ctrl + Pというショートカットで、コマンドパレットが開くので、検索欄から、「Open Settings(JSON)」を選択する。

Step3

settings.jsonをカキカキする。

settings.json
    "emeraldwalk.runonsave": {
        "commands": [
            {
                "match": "./*.py",
                "cmd": "echo python"
            },
            {
                "match": "./example_project/*",
                "cmd": "echo Hello World!"
            }
        ]
    }

matchで、対応したいファイルの範囲を設定。
cmdで、実行したいコマンドを入力。

出力先は、アウトプットパネルでRun On Saveを選択すれば出力されるー
Screenshot from 2021-02-05 10-47-52.png

終わりに

ナイスなアイディアあったら教えてくださいー

4
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
1