Giter Club home page Giter Club logo

vscode-file-watcher's Issues

File Watcher not detecting changes to files

File Watcher only runs when files are modified inside vscode. I was looking for a way to execute command in vscode when files are modified from other programs.

But maybe this is the expected behaviour ?

onFolderChange running "vscodeTask" as "cmd"

Hello. Thanks for making this extension.

I'm getting the following error output:

[Event handled] ...
[onFolderChange] for pattern "\.*" started
[vscode-task] gen-inits
[error] Error: command 'gen-inits' not found
[onFolderChange] for pattern "\.*" finished

Context:

I have the following VSCode setting defined:

{
  "match": "\\.*",
  "isAsync": true,
  "vscodeTask": "gen-inits",
  "event": "onFolderChange",
}

I have a gen-inits VSCode task defined, like so:

{
  "label": "gen-inits",
  "type": "shell",
  "command": "python ./scripts/gen_inits.py",
}

I am able to run the task through VSCode the normal way, but when it gets triggered from the event, I get the error output at the top. The error makes it sound like perhaps it is trying to run it as a cmd instead of a task.

Also, the onFolderChange event is getting triggered twice, just from saving my workspace file, even if I didn't actually make any changes. The strange thing is, it is not triggering any of the file events. I mean, from my perspective it doesn't seem like it should be triggering any events, because I didn't actually change anything. But if anything, I would expect it to trigger a file event, not a folder event.

[error] the input device is not a TTY. If you are using mintty, try prefixing the command with 'winpty'

Hi!

I have a following settings file:

{
  "filewatcher.commands": [
    {
      "match": "\\.puml",
      "isAsync": true,
      "cmd": "docker run --rm -it  --mount type=bind,source=${workspaceRoot},target=/app theplenkov/plantuml-docker",
      "event": "onFileChange"
    }
  ]
}

when i try to create any *.puml file i have output like this:

[Event handled] ...
[onFileChange] for pattern "\.puml" started
[cmd] docker run --rm -it  --mount type=bind,source=c:\Users\pplenkov\Documents\git_projects\comments-service,target=/app theplenkov/plantuml-docker
[error] the input device is not a TTY.  If you are using mintty, try prefixing the command with 'winpty'

Do you have any ideas why?

The command is working properly if input directly into CLI

External folder\file

Hi,
Does this extension support watching files or folder that resides outside the workspace? I tried several solutions but with no success.
Thanks,
Ron

autoClearConsole behaviour

Hi @VovanNet / @spostolsky,

What is the expected behaviour of autoClearConsole?

I am using it to trigger running tests when a file has changed.

settings.json

{
    "filewatcher.autoClearConsole": true,
    "filewatcher.commands": [
        {
            "match": "\\.php",
            "isAsync": false,
            "cmd": "cd ${workspaceRoot} && phpunit -v --group tdd",
            "event": "onFileChange"
        }
    ]
}

I am expecting it to clear the output before running the command but what is happening now is that it clears immediately after running. Which means I can't read the output of what was just executed.

If this is not the intended behaviour, how can I make it work like above, so I can read the output?

[error] TERM environment variable not set.

[Event handled] ...
[onFileChange] for pattern "/home/scratch.xiaolongs_gpu/temp/gdb_cmd_output.txt" started
[cmd] echo '/home/scratch.xiaolongs_gpu/temp/gdb_cmd_output.txt file content Changed' & /usr/bin/tcsh /home/xiaolongs/linuxScript/vscode/bin/vscode_open_file_goto_line.csh
[error] TERM environment variable not set.

[onFileChange]: for pattern "/home/scratch.xiaolongs_gpu/temp/gdb_cmd_output.txt" finished

I have tried below setting :
"cmd": "source /home/xiaolongs/linuxScript/vscode/bin/vscode_open_file_goto_line.csh ",
or
"cmd": "/usr/bin/tcsh /home/xiaolongs/linuxScript/vscode/bin/vscode_open_file_goto_line.csh ",

it seems it can't call a process script

Multiroot workspace path problems

Hi,
I have a multi folder workspace project setup in a WSL2 ubuntu that has some problems when trying to detect a filechange in another workspace folder.

The folders in the json below uses the vscode workspace base path as standard which is '/home/user/' and I tried to change the path to an absolute path from /home/ but then my workspace doesn’t work anymore ☹.

{
  "folders": [
    {
      "path": "repos/domain-backend"
    },
    {
      "path": "repos/domain-frontend"
    },
    {
      "path": "repos/domain-generator"
    },
    {
      "path": "repos/domain-signer"
    },
    {
      "path": "repos/domain-publisher"
    },
    {
      "path": "repos/other-backend"
    },
    {
      "path": "repos/other-frontend"
    }
  ],
  "settings": {
    "filewatcher.commands": [
      {
        "match": ".*\/com\/company\/domain\/.*.java",
        "isAsync": true,
        "cmd": "echo workspaceRoot=${workspaceRoot} \n workspaceRelativeDir=${workspaceRelativeDir} \n file=${file} \n fileOld=${fileOld} \n fileBasename=${fileBasename} \n fileDirname=${fileDirname} \n fileExtname=${fileExtname} \n fileBasenameNoExt=${fileBasenameNoExt}",
        "event": "onFileChange"
      },
    ]
  },
  "extensions": {
    "recommendations": []
  }
}

So, to the problem/issue. When the filewatcher executes on a change it bases the workspaceRoot on the top folder in folders array instead of the current working folder and the workspaceRelativeDir starts with ../ instead of /src/.

Output of the echo command

[cmd] echo workspaceRoot=/home/user/repos/domain-backend
 workspaceRelativeDir=../domain-signer/src/main/java/com/company/domain/signer/endpoints/SignerResource.java 
 file=/home/user/repos/domain-signer/src/main/java/com/company/domain/signer/endpoints/SignerResource.java 
 fileOld= 
 fileBasename=SignerResource.java 
 fileDirname=/home/user/repos/domain-signer/src/main/java/com/company/domain/signer/endpoints 
 fileExtname=.java 
 fileBasenameNoExt=SignerResource
workspaceRoot=/home/user/repos/domain-backend

If i instead execute it from the top folder in the previous json the echo looks like this

[cmd] echo workspaceRoot=/home/user/repos/domain-backend 
 workspaceRelativeDir=src/main/java/com/company/domain/backend/db/LocalDateConverter.java 
 file=/home/user/repos/domain-backend/src/main/java/com/company/domain/backend/db/LocalDateConverter.java 
 fileOld= 
 fileBasename=LocalDateConverter.java 
 fileDirname=/home/user/repos/domain-backend/src/main/java/com/company/domain/backend/db 
 fileExtname=.java 
 fileBasenameNoExt=LocalDateConverter
workspaceRoot=/home/user/repos/domain-backend

У вас расширение работает не в DEV режиме?

У вас расширение работает не в DEV режиме?

У меня ничего в консоль не сыпет по стандартному примеру.
Встроенные команды extension.enableFileWatcher тоже не работаю. При вызове "File watcher: enable" пишет "command 'extension.enableFileWatcher' not found".

Possible to change dir ?

Is it possible to change target directory

workspaceRoot:      d:\projects\foo-proj
file:               d:\projects\foo-proj\src\app\app.component.ts
fileBasename:       app.component.ts
fileBasenameNoExt:  app.component
fileExtname:        ts
fileDirname:        d:\projects\foo-proj\src\app

I need to change the src to dist

d:\projects\foo-proj\src\app\app.component.ts
d:\projects\foo-proj\dist\app\app.component.ts

VSCode prints error with usage of screeps-typescript-starter execution

When setting up a file watcher with this repo (https://github.com/screepers/screeps-typescript-starter), it prints [error] in two lines, and VSCode there were some errors.

Here is the output

Bildschirmfoto 2021-10-15 um 13 12 35

This is the code for the settings:

...
    "filewatcher.commands": [
        {
            "match": "\/Users\/mlostek\/Projects\/screeps\/my\/src\/.*",
            "isAsync": true,
            "cmd": "(cd ${workspaceRoot}; npm run push-main)",
            "event": "onFileChange"
        }
    ]
...

When i execute the command npm run push-main in a terminal, no error occurs.

Bildschirmfoto 2021-10-15 um 13 15 06

Any idea how to fix that?

(crosspost to the screeps template repo screepers/screeps-typescript-starter#161)

"shell" setting should expect a string value, not a number

Hi !

There seems to be an issue with the expected type of the shell setting.

Trying to set the shell to /bin/bash instead of the default /bin/sh using the GUI is not possible, as the input field does not accept string (initially, the value of the field was 0):

image

"The value should be a number"

This same message is displayed when setting the value in the settings.json:
image

Altough, in this case, saving the settings.json file is possible, in which case the shell value is properly used by the extension.

Still, it should be acceptable to set a string value for this setting, as a number doesn't make any sense here.

need notify

hi, I have been looking for similar plugins since a long time ago。finally,I found it。I want to be notified when the event fires,can u add this feature, thank u very much

it can't monitor remote peer to update the file content

I log in machines A and B.

I update file X on machine A ( which is run the gdb debugger, the file X is updated by gdb command) ,
I expect to monitor file X on machine B (which is running vscode), but the extension don't work as expected.

BTW, the extension works for the below scenario:
I update file X on A machine and monitor file X on machine A.

but it still has an issue:
if I only: "cmd": "echo '${file} file content Changed'",
it works.

if I call script : "cmd": "source '/home/xiaolongs/linuxScript/vscode/bin/vscode_open_file_goto_line.csh'",
it will report below error:
[error] /bin/sh: 1: source: not found
-- it seems it always uses the bash shell and not the related setting page. ( I am using the tcsh shell )

if I call script : "cmd": "tcsh '/home/xiaolongs/linuxScript/vscode/bin/vscode_open_file_goto_line.csh'",
it will report below error:
[error] TERM environment variable not set.

Publish to OpenVSX

Hi there!

Unfortunately, Microsoft prohibits the usage of the MS Extension Marketplace by any other non-microsoft products. Because of this, we kindly ask you to take the ownership of your namespace in OpenVSX and publish there as well.

OpenVSX is a vendor neutral alternative to the MS Marketplace used by all other derivatives of VS Code like Gitpod, OpenVSCode, VSCodium, Theia based IDEs, and so on.

The docs for publishing the extension are here: eclipse/openvsx/wiki/Publishing-Extensions. Technically this should be straightforward. You get a token and call ovsx publish with it. For example, this is how RedHat publishes their java extension: https://github.com/redhat-developer/vscode-java/blob/5d4f8d58b8e919534800ca7bc41e8513c288f573/Jenkinsfile#L78-L82.

Please do let me know if you are open to receive a PR contributing a release GitHub Action both to MS marketplace and OpenVSX. I'd love to help out!

Publish `file watcher` to Open VSX

Dear extension author,

I use this template to ask you : please publish this extension to the Open VSX marketplace. (there is a github action for that !)

Context

Unfortunately, as Microsoft prohibits usages of the Microsoft marketplace by any other products or redistribution of .vsix files from it, in order to use VS Code extensions in non-Microsoft products, we kindly ask that you take ownership of the VS Code extension namespace in Open VSX and publish this extension on Open VSX.

What is Open VSX? Why does it exist?

Open VSX is a vendor neutral alternative to the MS marketplace used by most other derivatives of VS Code like VSCodium, Gitpod, OpenVSCode, Theia-based IDEs, and so on.

You can read on about Open VSX at the Eclipse Foundation's Open VSX FAQ.

How can you publish to Open VSX?

The docs to publish an extension can be found here. This process is straightforward and shouldn't take too long. Essentially, you need an authentication token and to execute the ovsx publish command to publish your extension. There's also a doc explaining the whole process with an example GitHub Action workflow.

Thank you !

Expose API to allow other extensions depending on this one register custom watches

Hi, it'd be neat to allow programmatic registration of ICommands.

We have an extension which needs to do some file watching and rather than basically rewriting what you have here from scratch we'd like to do something like the following:

// code in activate() of our extension
let watcher = extensions.getExtension('filewatcher').exports; // also possibly activate the ext here
watcher.register({
  "match": "*.foo",
  "isAsync": true,
  "cmd": "echo '${file} bar'",
  "event": "onFileChange"
})

I haven't fully thought through how to show to the user what commands were registered this way. I guess there are multiple options - e.g. have some read-only view which would expose these, or dump these to some config file directly (probably not the user config).

Is this something you'd consider having in your extension? I'd be willing to contribute the patch if you agre to go through with this idea

code-workspace

I have this in my code-workspace, but it seems not picked up by file watcher:

	"settings": {
		"filewatcher.commands": [
			{
				"watch": "CspTest/vendor/theking2/csp-builder/composer.json",
				"cmd": "composer dump-autoload",
				"event": "onFileChange",
				"isAsync": true,
				
			}
		]
	},

is this correct here?

Commands not being executed

Hello, my team ran into an issue with a recent update where our commands were outputting to the console but not actually being executed. After a little digging it seems like this.execOption getter was resulting in {"shell": ""} which does not allow exec to run (at least on our MacBooks).

I ran the extension locally and was able to resolve this issue with by changing line 115 (file-watcher.ts) like so:
image

Alternatively I could set the global "filewatcher.shell" setting to something (e.g. "/bin/bash" and it started working again) but that's listed as an optional property in the docs.

Also our configuration used to be like the following, but the shell can no longer be set per command. This is not important to us, but may worth noting in case it affects others users.

"filewatcher.commands": [ { "shell": "/bin/bash", "match": "\\.js|\\.scss|\\.json|\\.html|\\.css", "isAsync": false, "cmd": "echo '${file} changed'", "event": "onFileChange" } ],

Happy to take a stab at a PR for this but you guys may have a better fix than my hack noted above.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.