New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

turbowatch

Package Overview
Dependencies
Maintainers
1
Versions
95
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

turbowatch - npm Package Compare versions

Comparing version 2.4.1 to 2.4.2

src/backends/.fixtures/bar

5

dist/backends/ChokidarWatcher.js

@@ -33,2 +33,4 @@ "use strict";

this.chokidar = chokidar.watch(project, {
awaitWriteFinish: false,
followSymlinks: true,
ignoreInitial: true,

@@ -39,2 +41,5 @@ });

this.chokidar.on('all', (event, filename) => {
if (event === 'addDir') {
return;
}
this.emit('change', { filename });

@@ -41,0 +46,0 @@ });

85

dist/backends/FileWatchingBackend.test.js

@@ -46,8 +46,2 @@ "use strict";

});
(0, vitest_1.afterEach)(async () => {
await promises_1.default.rm(fixturesPath, {
force: true,
recursive: true,
});
});
const waitForReady = (watcher) => {

@@ -83,8 +77,81 @@ return new Promise((resolve) => {

watcher.on('change', onChange);
await (0, promises_2.setTimeout)(100);
await promises_1.default.writeFile(node_path_1.default.join(fixturesPath, 'foo'), '');
await (0, promises_2.setTimeout)(1000);
(0, vitest_1.expect)(onChange.called).toBe(true);
(0, vitest_1.expect)(onChange.firstCall.args[0].filename).toBe(node_path_1.default.join(fixturesPath, 'foo'));
await (0, promises_2.setTimeout)(100);
(0, vitest_1.expect)(onChange.calledWith({
filename: node_path_1.default.join(fixturesPath, 'foo'),
})).toBe(true);
await watcher.close();
});
(0, vitest_1.it)('[' + name + '] detects changes to a file that is replaced', async () => {
const watcher = new Watcher(fixturesPath);
await waitForReady(watcher);
const onChange = sinon.stub();
watcher.on('change', onChange);
await (0, promises_2.setTimeout)(100);
await promises_1.default.writeFile(node_path_1.default.join(fixturesPath, 'foo'), '');
await (0, promises_2.setTimeout)(100);
await promises_1.default.unlink(node_path_1.default.join(fixturesPath, 'foo'));
await (0, promises_2.setTimeout)(100);
await promises_1.default.writeFile(node_path_1.default.join(fixturesPath, 'foo'), '');
await (0, promises_2.setTimeout)(100);
(0, vitest_1.expect)(onChange.callCount).toBeGreaterThanOrEqual(3);
await watcher.close();
});
(0, vitest_1.it)('[' + name + '] detects hard link change (linked file)', async () => {
await promises_1.default.mkdir(node_path_1.default.resolve(fixturesPath, 'foo'));
await promises_1.default.writeFile(node_path_1.default.join(fixturesPath, 'bar'), '');
await promises_1.default.link(node_path_1.default.join(fixturesPath, 'bar'), node_path_1.default.join(fixturesPath, 'foo', 'bar'));
const watcher = new Watcher(node_path_1.default.resolve(fixturesPath, 'foo'));
await waitForReady(watcher);
const onChange = sinon.stub();
watcher.on('change', onChange);
await (0, promises_2.setTimeout)(100);
await promises_1.default.writeFile(node_path_1.default.join(fixturesPath, 'bar'), '');
await (0, promises_2.setTimeout)(100);
(0, vitest_1.expect)(onChange.calledWith({
filename: node_path_1.default.join(fixturesPath, 'foo', 'bar'),
})).toBe(true);
await watcher.close();
});
(0, vitest_1.it)('[' + name + '] detects symlink change (linked file)', async () => {
await promises_1.default.mkdir(node_path_1.default.resolve(fixturesPath, 'foo'));
await promises_1.default.writeFile(node_path_1.default.join(fixturesPath, 'bar'), '');
await promises_1.default.symlink(node_path_1.default.join(fixturesPath, 'bar'), node_path_1.default.join(fixturesPath, 'foo', 'bar'));
const watcher = new Watcher(node_path_1.default.resolve(fixturesPath, 'foo'));
await waitForReady(watcher);
const onChange = sinon.stub();
watcher.on('change', onChange);
await (0, promises_2.setTimeout)(100);
await promises_1.default.writeFile(node_path_1.default.join(fixturesPath, 'bar'), '');
await (0, promises_2.setTimeout)(100);
(0, vitest_1.expect)(onChange.calledWith({
filename: node_path_1.default.join(fixturesPath, 'foo', 'bar'),
})).toBe(true);
await watcher.close();
});
vitest_1.it.skip('[' + name + '] detects symlink change (linked path)', async () => {
await promises_1.default.mkdir(node_path_1.default.resolve(fixturesPath, 'foo'));
await promises_1.default.mkdir(node_path_1.default.resolve(fixturesPath, 'bar'));
await promises_1.default.writeFile(node_path_1.default.join(fixturesPath, 'bar', 'baz'), '');
await promises_1.default.symlink(node_path_1.default.join(fixturesPath, 'bar'), node_path_1.default.join(fixturesPath, 'foo', 'bar'));
const watcher = new Watcher(node_path_1.default.resolve(fixturesPath, 'foo'));
await waitForReady(watcher);
const onChange = sinon.stub();
watcher.on('change', onChange);
await (0, promises_2.setTimeout)(100);
await promises_1.default.writeFile(node_path_1.default.join(fixturesPath, 'bar', 'baz'), '');
await (0, promises_2.setTimeout)(100);
// TODO fix this test
// expect(
// onChange.calledWith({
// filename: path.join(fixturesPath, 'foo', 'bar', 'baz'),
// }),
// ).toBe(true);
(0, vitest_1.expect)(onChange.calledWith({
filename: node_path_1.default.join(fixturesPath, 'foo', 'bar'),
})).toBe(true);
await watcher.close();
});
}
//# sourceMappingURL=FileWatchingBackend.test.js.map

@@ -0,2 +1,3 @@

#!/usr/bin/env node
export {};
//# sourceMappingURL=turbowatch.d.ts.map

@@ -0,2 +1,4 @@

#!/usr/bin/env node
"use strict";
/* eslint-disable node/shebang */
/* eslint-disable no-console */

@@ -3,0 +5,0 @@ var __importDefault = (this && this.__importDefault) || function (mod) {

2

package.json

@@ -64,3 +64,3 @@ {

"types": "./dist/index.d.ts",
"version": "2.4.1"
"version": "2.4.2"
}

@@ -11,2 +11,4 @@ import { FileWatchingBackend } from './FileWatchingBackend';

this.chokidar = chokidar.watch(project, {
awaitWriteFinish: false,
followSymlinks: true,
ignoreInitial: true,

@@ -19,2 +21,6 @@ });

this.chokidar.on('all', (event, filename) => {
if (event === 'addDir') {
return;
}
this.emit('change', { filename });

@@ -21,0 +27,0 @@ });

@@ -10,3 +10,3 @@ import { isFSWatcherAvailable } from '../isFSWatcherAvailable';

import * as sinon from 'sinon';
import { afterEach, beforeEach, expect, it } from 'vitest';
import { beforeEach, expect, it } from 'vitest';

@@ -24,9 +24,2 @@ const fixturesPath = path.resolve(__dirname, '.fixtures');

afterEach(async () => {
await fs.rm(fixturesPath, {
force: true,
recursive: true,
});
});
const waitForReady = (watcher: FileWatchingBackend) => {

@@ -69,12 +62,150 @@ return new Promise((resolve) => {

await setTimeout(100);
await fs.writeFile(path.join(fixturesPath, 'foo'), '');
await setTimeout(1_000);
await setTimeout(100);
expect(onChange.called).toBe(true);
expect(
onChange.calledWith({
filename: path.join(fixturesPath, 'foo'),
}),
).toBe(true);
expect(onChange.firstCall.args[0].filename).toBe(
path.join(fixturesPath, 'foo'),
await watcher.close();
});
it('[' + name + '] detects changes to a file that is replaced', async () => {
const watcher = new Watcher(fixturesPath);
await waitForReady(watcher);
const onChange = sinon.stub();
watcher.on('change', onChange);
await setTimeout(100);
await fs.writeFile(path.join(fixturesPath, 'foo'), '');
await setTimeout(100);
await fs.unlink(path.join(fixturesPath, 'foo'));
await setTimeout(100);
await fs.writeFile(path.join(fixturesPath, 'foo'), '');
await setTimeout(100);
expect(onChange.callCount).toBeGreaterThanOrEqual(3);
await watcher.close();
});
it('[' + name + '] detects hard link change (linked file)', async () => {
await fs.mkdir(path.resolve(fixturesPath, 'foo'));
await fs.writeFile(path.join(fixturesPath, 'bar'), '');
await fs.link(
path.join(fixturesPath, 'bar'),
path.join(fixturesPath, 'foo', 'bar'),
);
const watcher = new Watcher(path.resolve(fixturesPath, 'foo'));
await waitForReady(watcher);
const onChange = sinon.stub();
watcher.on('change', onChange);
await setTimeout(100);
await fs.writeFile(path.join(fixturesPath, 'bar'), '');
await setTimeout(100);
expect(
onChange.calledWith({
filename: path.join(fixturesPath, 'foo', 'bar'),
}),
).toBe(true);
await watcher.close();
});
it('[' + name + '] detects symlink change (linked file)', async () => {
await fs.mkdir(path.resolve(fixturesPath, 'foo'));
await fs.writeFile(path.join(fixturesPath, 'bar'), '');
await fs.symlink(
path.join(fixturesPath, 'bar'),
path.join(fixturesPath, 'foo', 'bar'),
);
const watcher = new Watcher(path.resolve(fixturesPath, 'foo'));
await waitForReady(watcher);
const onChange = sinon.stub();
watcher.on('change', onChange);
await setTimeout(100);
await fs.writeFile(path.join(fixturesPath, 'bar'), '');
await setTimeout(100);
expect(
onChange.calledWith({
filename: path.join(fixturesPath, 'foo', 'bar'),
}),
).toBe(true);
await watcher.close();
});
it.skip('[' + name + '] detects symlink change (linked path)', async () => {
await fs.mkdir(path.resolve(fixturesPath, 'foo'));
await fs.mkdir(path.resolve(fixturesPath, 'bar'));
await fs.writeFile(path.join(fixturesPath, 'bar', 'baz'), '');
await fs.symlink(
path.join(fixturesPath, 'bar'),
path.join(fixturesPath, 'foo', 'bar'),
);
const watcher = new Watcher(path.resolve(fixturesPath, 'foo'));
await waitForReady(watcher);
const onChange = sinon.stub();
watcher.on('change', onChange);
await setTimeout(100);
await fs.writeFile(path.join(fixturesPath, 'bar', 'baz'), '');
await setTimeout(100);
// TODO fix this test
// expect(
// onChange.calledWith({
// filename: path.join(fixturesPath, 'foo', 'bar', 'baz'),
// }),
// ).toBe(true);
expect(
onChange.calledWith({
filename: path.join(fixturesPath, 'foo', 'bar'),
}),
).toBe(true);
await watcher.close();
});
}

@@ -0,1 +1,4 @@

#!/usr/bin/env node
/* eslint-disable node/shebang */
/* eslint-disable no-console */

@@ -2,0 +5,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc