3

Is there a way to set up file watcher in PhpStorm on one file, that will copy that file to different location in project after file change/save?

LazyOne
  • 158,824
  • 45
  • 388
  • 391
IProSoft
  • 173
  • 1
  • 8
  • What exactly the purposes of this? Because there could be 2 solutions: 1) using Deployment -- it can do auto deployment of all modified files (unless excluded); target can be another folder/network disk .. or proper remote host; 2) File Watcher -- works on actual modified files; you just need to create a batch/shell script that will copy those files for you (e.g. standard `copy` command on Windows) and use that script in `program` filed of File Watcher (and pass file name as a parameter) – LazyOne Jan 03 '17 at 15:15
  • Number 2 - thanks for tip, I'll create bash script as program and try it out – IProSoft Jan 04 '17 at 22:32

2 Answers2

2

As pointed in this other Answer is better to use robocopy.

I created a Watcher with WebStorm > Settings > Tools > File Watchers:

  • File type: any
  • Scope: Changed Files
  • Program: C:\Windows\System32\robocopy.exe
  • Arguments: $FileDir$ C:\MyDestinationDir\$FileDirRelativeToProjectRoot$ $FileName$
  • Working Directory: $ProjectFileDir$\src
Gabrielizalo
  • 896
  • 1
  • 17
  • 29
1

You don't even need a batch/shell script for this as has been suggested in comments. You can just use xcopy.exe as a program. On Windows 10 it resides in C:\Windows\System32 folder.

One way to set it up would be:

Arguments: src\$FileName$ dist /iy

Working directory: $ProjectFileDir$

In this case you are copying top-level files from src directory to dist directory of your project. /i tells xcopy that the destination is a folder and /y supresses the prompt to confirm overwriting.