flow like the river

This commit is contained in:
root 2025-11-07 00:06:12 +01:00
commit 013fe673f3
42435 changed files with 5764238 additions and 0 deletions

8
BACK_BACK/node_modules/@parcel/watcher/test/.babelrc generated vendored Executable file
View file

@ -0,0 +1,8 @@
{
"presets": [["@babel/preset-env", {
"targets": {
"node": "current"
}
}]],
"plugins": ["@babel/plugin-transform-runtime"]
}

6
BACK_BACK/node_modules/@parcel/watcher/test/.eslintrc.json generated vendored Executable file
View file

@ -0,0 +1,6 @@
{
"extends": "../../../../.eslintrc.json",
"env": {
"mocha": true
}
}

104
BACK_BACK/node_modules/@parcel/watcher/test/changeEvent.js generated vendored Executable file
View file

@ -0,0 +1,104 @@
const Watcher = require('../index');
const fs = require('@parcel/fs');
const path = require('path');
const assert = require('assert');
const {sleep} = require('@parcel/test-utils');
describe('change event', function() {
let tmpFolder = path.join(__dirname, './tmp/');
before(() => {
fs.mkdirp(tmpFolder);
});
it('Should emit event on filechange', async () => {
let watcher = new Watcher({});
let filepath = path.join(tmpFolder, 'file1.txt');
await fs.writeFile(filepath, 'this is a text document');
watcher.add(filepath);
let changed = false;
watcher.once('change', () => {
changed = true;
});
if (!watcher.ready) {
await new Promise(resolve => watcher.once('ready', resolve));
}
await sleep(250);
await fs.writeFile(filepath, 'this is not a text document');
await sleep(500);
assert(changed, 'File should be flagged as changed.');
await watcher.stop();
});
it('Should emit event on filechange using arrays', async () => {
let watcher = new Watcher({});
let filepath = path.join(tmpFolder, 'file1.txt');
await fs.writeFile(filepath, 'this is a text document');
watcher.add([filepath]);
let changed = false;
watcher.once('change', () => {
changed = true;
});
if (!watcher.ready) {
await new Promise(resolve => watcher.once('ready', resolve));
}
await sleep(250);
await fs.writeFile(filepath, 'this is not a text document');
await sleep(500);
assert(changed, 'File should be flagged as changed.');
await watcher.stop();
});
it('Should not emit event if file has been added and removed', async () => {
let watcher = new Watcher({});
let filepath = path.join(tmpFolder, 'file1.txt');
await fs.writeFile(filepath, 'this is a text document');
await sleep(250);
watcher.add(filepath);
let changed = false;
watcher.once('change', () => {
changed = true;
});
if (!watcher.ready) {
await new Promise(resolve => watcher.once('ready', resolve));
}
await sleep(250);
watcher.unwatch(filepath);
await fs.writeFile(filepath, 'this is not a text document');
await sleep(500);
assert(!changed, 'Should not have emitted a change event.');
await watcher.stop();
});
});

84
BACK_BACK/node_modules/@parcel/watcher/test/errorHandling.js generated vendored Executable file
View file

@ -0,0 +1,84 @@
const Watcher = require('../index');
const fs = require('@parcel/fs');
const path = require('path');
const assert = require('assert');
const {sleep} = require('@parcel/test-utils');
describe('error handling', function() {
let tmpFolder = path.join(__dirname, './tmp/');
before(() => {
fs.mkdirp(tmpFolder);
});
it('Should restart child process if it dies', async () => {
let watcher = new Watcher({});
let filepath = path.join(tmpFolder, 'file1.txt');
await fs.writeFile(filepath, 'this is a text document');
watcher.add(filepath);
let changed = false;
watcher.once('change', () => {
changed = true;
});
if (!watcher.ready) {
await new Promise(resolve => watcher.once('ready', resolve));
}
await sleep(250);
watcher._emulateChildDead();
await sleep(1000);
await fs.writeFile(filepath, 'this is not a text document');
await sleep(500);
assert(changed, 'Should have emitted a change event.');
await watcher.stop();
});
it('Should restart child process on errors', async () => {
let watcher = new Watcher({});
let filepath = path.join(tmpFolder, 'file1.txt');
await fs.writeFile(filepath, 'this is a text document');
watcher.add(filepath);
let hasThrown = false;
watcher.on('watcherError', () => (hasThrown = true));
let changed = false;
watcher.once('change', () => {
changed = true;
});
if (!watcher.ready) {
await new Promise(resolve => watcher.once('ready', resolve));
}
await sleep(250);
watcher._emulateChildError();
await sleep(1000);
await fs.writeFile(filepath, 'this is not a text document');
await sleep(500);
assert(changed, 'Should have emitted a change event.');
await watcher.stop();
assert(hasThrown, 'Should have emitted an error event.');
});
});

31
BACK_BACK/node_modules/@parcel/watcher/test/fswatcher.js generated vendored Executable file
View file

@ -0,0 +1,31 @@
const Watcher = require('../index');
const {sleep} = require('@parcel/test-utils');
const assert = require('assert');
describe('Watcher', function() {
it('Should be able to create a new watcher', async () => {
let watcher = new Watcher();
assert(!!watcher.child);
assert(!watcher.ready);
await sleep(1000);
assert(!!watcher.child);
assert(watcher.ready);
await watcher.stop();
});
it('Should be able to properly destroy the watcher', async () => {
let watcher = new Watcher();
await sleep(1000);
assert(!!watcher.child);
assert(watcher.ready);
await watcher.stop();
assert(watcher.child.killed);
});
});

3
BACK_BACK/node_modules/@parcel/watcher/test/mocha.opts generated vendored Executable file
View file

@ -0,0 +1,3 @@
--require @parcel/babel-register
--timeout 10000
--exit

124
BACK_BACK/node_modules/@parcel/watcher/test/options.js generated vendored Executable file
View file

@ -0,0 +1,124 @@
const Watcher = require('../index');
const fs = require('@parcel/fs');
const path = require('path');
const assert = require('assert');
const {sleep} = require('@parcel/test-utils');
describe('options', function() {
let tmpFolder = path.join(__dirname, './tmp/');
before(() => {
fs.mkdirp(tmpFolder);
});
it('Should pass init options with correct ignored regex', async () => {
let watcher = new Watcher({
ignored: /file/
});
let filepath = path.join(tmpFolder, 'file1.txt');
await fs.writeFile(filepath, 'this is a text document');
watcher.add(filepath);
let changed = false;
watcher.once('change', () => {
changed = true;
});
if (!watcher.ready) {
await new Promise(resolve => watcher.once('ready', resolve));
}
await sleep(250);
await fs.writeFile(filepath, 'this is not a text document');
await sleep(500);
assert(!changed, 'File should not be flagged as changed.');
await watcher.stop();
});
it('Should pass init options with a more complex ignored regex', async () => {
let watcher = new Watcher({
ignored: /file|config/
});
let filepaths = [
path.join(tmpFolder, 'file1.txt'),
path.join(tmpFolder, 'config.json')
];
for (let filepath of filepaths) {
await fs.writeFile(filepath, 'this is a text document');
watcher.add(filepath);
}
let changed = false;
watcher.once('change', () => {
changed = true;
});
if (!watcher.ready) {
await new Promise(resolve => watcher.once('ready', resolve));
}
await sleep(250);
for (let filepath of filepaths) {
await fs.writeFile(filepath, 'this is not a text document');
watcher.add(filepath);
}
await sleep(500);
assert(!changed, 'File should not be flagged as changed.');
await watcher.stop();
});
it('Should not ignore any files outside of the regex', async () => {
let watcher = new Watcher({
ignored: /file|config/
});
let filepaths = [
path.join(tmpFolder, 'file1.txt'),
path.join(tmpFolder, 'config.json'),
path.join(tmpFolder, 'something')
];
for (let filepath of filepaths) {
await fs.writeFile(filepath, 'this is a text document');
watcher.add(filepath);
}
let changed = 0;
watcher.once('change', () => {
changed++;
});
if (!watcher.ready) {
await new Promise(resolve => watcher.once('ready', resolve));
}
await sleep(250);
for (let filepath of filepaths) {
await fs.writeFile(filepath, 'this is not a text document');
watcher.add(filepath);
}
await sleep(500);
assert.equal(changed, 1, 'One file should have changed once.');
await watcher.stop();
});
});

View file

@ -0,0 +1 @@
this is not a text document

1
BACK_BACK/node_modules/@parcel/watcher/test/tmp/file1.txt generated vendored Executable file
View file

@ -0,0 +1 @@
this is a text document

1
BACK_BACK/node_modules/@parcel/watcher/test/tmp/something generated vendored Executable file
View file

@ -0,0 +1 @@
this is not a text document

28
BACK_BACK/node_modules/@parcel/watcher/test/watched.js generated vendored Executable file
View file

@ -0,0 +1,28 @@
const Watcher = require('../index');
const fs = require('@parcel/fs');
const path = require('path');
const assert = require('assert');
describe('watched paths', function() {
let tmpFolder = path.join(__dirname, './tmp/');
before(() => {
fs.mkdirp(tmpFolder);
});
it('Should return watched paths', async () => {
let watcher = new Watcher({});
let filepath = path.join(tmpFolder, 'file1.txt');
await fs.writeFile(filepath, 'this is a text document');
watcher.add(filepath);
assert(
Object.keys(watcher.getWatched())[0] === filepath,
'getWatched should return all the watched paths.'
);
await watcher.stop();
});
});