question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Using an absolute path added events do not fire

See original GitHub issue

I can add these tests as a PR if you want. But first I wanted to make sure that my thought process on this was correct. These tests are simply copies of current tests. Or are such patterns not supported?

  addedByAbsolutePath: function(test) {
    test.expect(1);
    gaze(process.cwd() + '/**/*', function(err, watcher) {
      setTimeout(function() {
        test.ok(false, 'Ended without adding a file.');
        watcher.close();
      }, 1000);
      this.on('added', function(filepath) {
        var expected = path.relative(process.cwd(), filepath);
        test.equal(path.join('sub', 'tmp.js'), expected);
        watcher.close();
      });
      this.on('changed', function() { test.ok(false, 'changed event should not have emitted.'); });
      this.on('deleted', function() { test.ok(false, 'deleted event should not have emitted.'); });
      fs.writeFileSync(path.resolve(__dirname, 'fixtures', 'sub', 'tmp.js'), 'var tmp = true;');
      watcher.on('end', test.done);
    });
  },
  dontAddUnmatchedFilesByAbsolutePath: function(test) {
    // TODO: Code smell
    test.expect(2);
    gaze(process.cwd() + '/**/*.js', function(err, watcher) {
      setTimeout(function() {
        test.ok(true, 'Ended without adding a file.');
        watcher.close();
      }, 1000);
      this.on('added', function(filepath) {
        test.equal(path.relative(process.cwd(), filepath), path.join('sub', 'tmp.js'));
      });
      fs.writeFileSync(path.resolve(__dirname, 'fixtures', 'sub', 'tmp'), 'Dont add me!');
      fs.writeFileSync(path.resolve(__dirname, 'fixtures', 'sub', 'tmp.js'), 'add me!');
      watcher.on('end', test.done);
    });
  },

Issue Analytics

  • State:open
  • Created 10 years ago
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
seebeescommented, Mar 21, 2014

Ok. I see it here. The npm and README documentation needs to be updated. If I get time I’ll give you a PR.

But… When I test this I see that

cwd = /path/to/some/ and pattern = files/**/*js does not fire the add event but cwd = /path/to/some/files/ and pattern = **/*.js does

again, I can work around it but is the expectation that the first one will not fire add events? or do you want a test for that case?

0reactions
hedefalkcommented, Mar 31, 2016

+1, I tried to replace chokidar because it didn’t build on Atom/Electron because fsevents. I just wanted to watch an absolute file name, but that doesn’t seem possible. So I tried to break it down and use cwd, but that seems broken on empty folders too. I did an outside test:

https://gist.github.com/hedefalk/adccbaeb10c7285686d19e9263fda6c5

I’m gonna try something else 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

HTML input file selection event not firing upon selecting the ...
10 Answers 10 · 2. I tried the demo, but (using Chrome 21) I keep getting `C:\fakepath` + then the filename I selected...
Read more >
(Absolute path (...) is not supported. Please specify a relative ...
Please specify a relative path.)" error occurs when adding physical address in MicroStrategy Web 9.x. "Unable to create address with the ...
Read more >
Events that trigger workflows - GitHub Docs
You can configure your workflows to run when specific activity on GitHub happens, at a scheduled time, or when an event outside of...
Read more >
Azure Blob storage trigger for Azure Functions | Microsoft Learn
For more information, see Tutorial: Trigger Azure Functions on blob containers using an event subscription. Blob name string is manually added ...
Read more >
Page view triggers - Tag Manager Help - Google Support
Use Google Tag Manager's page view triggers to fire tags when pages are loaded in web ... There are five trigger types that...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found