test
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
mol
2024-07-06 22:23:31 +08:00
parent 08173d8497
commit 263cb5ef03
1663 changed files with 526884 additions and 0 deletions

View File

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2017-present Devon Govett
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

Binary file not shown.

View File

@ -0,0 +1,77 @@
const binding = require('node-gyp-build')(__dirname);
const path = require('path');
const micromatch = require('micromatch');
const isGlob = require('is-glob');
function normalizeOptions(dir, opts = {}) {
const { ignore, ...rest } = opts;
if (Array.isArray(ignore)) {
opts = { ...rest };
for (const value of ignore) {
if (isGlob(value)) {
if (!opts.ignoreGlobs) {
opts.ignoreGlobs = [];
}
const regex = micromatch.makeRe(value, {
// We set `dot: true` to workaround an issue with the
// regular expression on Linux where the resulting
// negative lookahead `(?!(\\/|^)` was never matching
// in some cases. See also https://bit.ly/3UZlQDm
dot: true,
// C++ does not support lookbehind regex patterns, they
// were only added later to JavaScript engines
// (https://bit.ly/3V7S6UL)
lookbehinds: false
});
opts.ignoreGlobs.push(regex.source);
} else {
if (!opts.ignorePaths) {
opts.ignorePaths = [];
}
opts.ignorePaths.push(path.resolve(dir, value));
}
}
}
return opts;
}
exports.writeSnapshot = (dir, snapshot, opts) => {
return binding.writeSnapshot(
path.resolve(dir),
path.resolve(snapshot),
normalizeOptions(dir, opts),
);
};
exports.getEventsSince = (dir, snapshot, opts) => {
return binding.getEventsSince(
path.resolve(dir),
path.resolve(snapshot),
normalizeOptions(dir, opts),
);
};
exports.subscribe = async (dir, fn, opts) => {
dir = path.resolve(dir);
opts = normalizeOptions(dir, opts);
await binding.subscribe(dir, fn, opts);
return {
unsubscribe() {
return binding.unsubscribe(dir, fn, opts);
},
};
};
exports.unsubscribe = (dir, fn, opts) => {
return binding.unsubscribe(
path.resolve(dir),
fn,
normalizeOptions(dir, opts),
);
};

View File

@ -0,0 +1,48 @@
// @flow
declare type FilePath = string;
declare type GlobPattern = string;
export type BackendType =
| 'fs-events'
| 'watchman'
| 'inotify'
| 'windows'
| 'brute-force';
export type EventType = 'create' | 'update' | 'delete';
export interface Options {
ignore?: Array<FilePath | GlobPattern>,
backend?: BackendType
}
export type SubscribeCallback = (
err: ?Error,
events: Array<Event>
) => mixed;
export interface AsyncSubscription {
unsubscribe(): Promise<void>
}
export interface Event {
path: FilePath,
type: EventType
}
declare module.exports: {
getEventsSince(
dir: FilePath,
snapshot: FilePath,
opts?: Options
): Promise<Array<Event>>,
subscribe(
dir: FilePath,
fn: SubscribeCallback,
opts?: Options
): Promise<AsyncSubscription>,
unsubscribe(
dir: FilePath,
fn: SubscribeCallback,
opts?: Options
): Promise<void>,
writeSnapshot(
dir: FilePath,
snapshot: FilePath,
opts?: Options
): Promise<FilePath>
}

View File

@ -0,0 +1,69 @@
{
"name": "@parcel/watcher",
"version": "2.1.0",
"main": "index.js",
"types": "index.d.ts",
"repository": {
"type": "git",
"url": "https://github.com/parcel-bundler/watcher.git"
},
"description": "A native C++ Node module for querying and subscribing to filesystem events. Used by Parcel 2.",
"license": "MIT",
"publishConfig": {
"access": "public"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/parcel"
},
"files": [
"src",
"prebuilds",
"index.js",
"index.js.flow",
"index.d.ts",
"package.json",
"binding.gyp",
"README.md"
],
"scripts": {
"prebuild": "prebuildify --napi --strip --tag-libc -t 10.0.0",
"format": "prettier --write \"./**/*.{js,json,md}\"",
"install": "node-gyp-build",
"rebuild": "node-gyp rebuild -j 8 --debug --verbose",
"test": "mocha"
},
"engines": {
"node": ">= 10.0.0"
},
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
"lint-staged": {
"*.{js,json,md}": [
"prettier --write",
"git add"
]
},
"dependencies": {
"is-glob": "^4.0.3",
"micromatch": "^4.0.5",
"node-addon-api": "^3.2.1",
"node-gyp-build": "^4.3.0"
},
"devDependencies": {
"fs-extra": "^10.0.0",
"husky": "^7.0.2",
"lint-staged": "^11.1.2",
"mocha": "^9.1.1",
"prebuildify": "^4.2.1",
"prettier": "^2.3.2"
},
"binary": {
"napi_versions": [
3
]
}
}