Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

242
Views
Watch project dependencies using VSCode API

I am writing a VSCode extension and I need a way to know when a project gets a new dependency to trigger some action. For that, I decided to watch package.json file using 'fs.watchFile'. But the problem is that fs sees the change only after saving the file and it takes a second or two. Moreover, if a user adds a new dependency manually to package.json there is no change event until the user saves it. I wonder if VSCode has some internal API that will do it better than fs.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

VSCode has a nice utility for that vscode.workspace.createFileSystemWatcher. It's better than fs implementation because it is also triggered when the file is 'dirty' before it is saved. Possible implementation is:

const watcher = vscode.workspace.createFileSystemWatcher(
  packageJsonPath, // absolute path to package.json
  true, // ignore create events
  false, // don't ignore change events
  true, // ignore delete events
);
watcher.onDidChange(() => {
    // trigger some action
})

// when not needed
if (watcher) {
  watcher.dispose();
}
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!