@miniflare/watcher
Advanced tools
Comparing version 2.0.0-rc.3 to 2.0.0-rc.4
@@ -0,11 +1,38 @@ | ||
var __create = Object.create; | ||
var __defProp = Object.defineProperty; | ||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor; | ||
var __getOwnPropNames = Object.getOwnPropertyNames; | ||
var __getProtoOf = Object.getPrototypeOf; | ||
var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true }); | ||
var __export = (target, all) => { | ||
__markAsModule(target); | ||
for (var name in all) | ||
__defProp(target, name, { get: all[name], enumerable: true }); | ||
}; | ||
var __reExport = (target, module2, desc) => { | ||
if (module2 && typeof module2 === "object" || typeof module2 === "function") { | ||
for (let key of __getOwnPropNames(module2)) | ||
if (!__hasOwnProp.call(target, key) && key !== "default") | ||
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable }); | ||
} | ||
return target; | ||
}; | ||
var __toModule = (module2) => { | ||
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", module2 && module2.__esModule && "default" in module2 ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2); | ||
}; | ||
// packages/watcher/src/index.ts | ||
import assert from "assert"; | ||
import fs from "fs"; | ||
import path from "path"; | ||
import { debuglog } from "util"; | ||
var fsp = fs.promises; | ||
var log = debuglog("mf-watch"); | ||
__export(exports, { | ||
Watcher: () => Watcher | ||
}); | ||
var import_assert = __toModule(require("assert")); | ||
var import_fs = __toModule(require("fs")); | ||
var import_path = __toModule(require("path")); | ||
var import_util = __toModule(require("util")); | ||
var fsp = import_fs.default.promises; | ||
var log = (0, import_util.debuglog)("mf-watch"); | ||
function withinDir(dir, file) { | ||
const rel = path.relative(dir, file); | ||
return !!rel && !rel.startsWith("..") && !path.isAbsolute(rel); | ||
const rel = import_path.default.relative(dir, file); | ||
return !!rel && !rel.startsWith("..") && !import_path.default.isAbsolute(rel); | ||
} | ||
@@ -16,3 +43,3 @@ async function walkDirs(root, callback) { | ||
await Promise.all(names.map(async (name) => { | ||
const filePath = path.join(root, name); | ||
const filePath = import_path.default.join(root, name); | ||
if (!(await fsp.stat(filePath)).isDirectory()) | ||
@@ -37,3 +64,3 @@ return; | ||
startCreateWatcher() { | ||
assert(!this.watching); | ||
(0, import_assert.default)(!this.watching); | ||
log(`${this.filePath}: polling for create...`); | ||
@@ -44,3 +71,3 @@ this.watchFileListener = (curr) => { | ||
log(`${this.filePath}: created, tidying up temporary watcher...`); | ||
fs.unwatchFile(this.filePath, this.watchFileListener); | ||
import_fs.default.unwatchFile(this.filePath, this.watchFileListener); | ||
this.watchFileListener = void 0; | ||
@@ -50,6 +77,6 @@ this.callback(); | ||
}; | ||
fs.watchFile(this.filePath, { interval: this.options.createPollInterval }, this.watchFileListener); | ||
import_fs.default.watchFile(this.filePath, { interval: this.options.createPollInterval }, this.watchFileListener); | ||
} | ||
startPollingWatcher() { | ||
assert(!this.watching); | ||
(0, import_assert.default)(!this.watching); | ||
log(`${this.filePath}: polling...`); | ||
@@ -66,3 +93,3 @@ this.watchFileListener = (curr, prev) => { | ||
}; | ||
fs.watchFile(this.filePath, { interval: this.options.pollInterval }, this.watchFileListener); | ||
import_fs.default.watchFile(this.filePath, { interval: this.options.pollInterval }, this.watchFileListener); | ||
} | ||
@@ -73,3 +100,3 @@ listener = async (event, fileName) => { | ||
try { | ||
const resolved = path.resolve(this.filePath, fileName); | ||
const resolved = import_path.default.resolve(this.filePath, fileName); | ||
const mtime = (await fsp.stat(resolved)).mtimeMs; | ||
@@ -86,3 +113,3 @@ const previousMtime = this.lastMtimes?.get(resolved); | ||
this.callback(); | ||
if (!fs.existsSync(this.filePath)) { | ||
if (!import_fs.default.existsSync(this.filePath)) { | ||
this.dispose(); | ||
@@ -100,13 +127,13 @@ this.startCreateWatcher(); | ||
}; | ||
fs.watchFile(this.filePath, { interval: this.options.pollInterval }, this.watchFileListener); | ||
import_fs.default.watchFile(this.filePath, { interval: this.options.pollInterval }, this.watchFileListener); | ||
} | ||
startPlatformRecursiveWatcher() { | ||
assert(!this.watching); | ||
(0, import_assert.default)(!this.watching); | ||
log(`${this.filePath}: recursively watching with platform...`); | ||
this.lastMtimes = new Map(); | ||
this.watcher = fs.watch(this.filePath, { recursive: true }, this.listener); | ||
this.watcher = import_fs.default.watch(this.filePath, { recursive: true }, this.listener); | ||
this.startDeletedWatcher(); | ||
} | ||
async startRecursiveWatcher() { | ||
assert(!this.watching); | ||
(0, import_assert.default)(!this.watching); | ||
log(`${this.filePath}: recursively watching...`); | ||
@@ -128,3 +155,3 @@ const watchers = this.watchers = new Map(); | ||
} | ||
const filePath = path.join(dir, fileName); | ||
const filePath = import_path.default.join(dir, fileName); | ||
await this.listener(event, filePath); | ||
@@ -149,3 +176,3 @@ try { | ||
if (!watchers.has(dir)) { | ||
watchers.set(dir, fs.watch(dir, update.bind(this, dir))); | ||
watchers.set(dir, import_fs.default.watch(dir, update.bind(this, dir))); | ||
} | ||
@@ -189,3 +216,3 @@ }; | ||
if (this.watchFileListener) { | ||
fs.unwatchFile(this.filePath, this.watchFileListener); | ||
import_fs.default.unwatchFile(this.filePath, this.watchFileListener); | ||
this.watchFileListener = void 0; | ||
@@ -201,3 +228,3 @@ } | ||
this.lastMtimes = void 0; | ||
assert(!this.watching); | ||
(0, import_assert.default)(!this.watching); | ||
} | ||
@@ -222,3 +249,3 @@ }; | ||
for (const rawPath of paths) { | ||
const resolved = path.resolve(rawPath); | ||
const resolved = import_path.default.resolve(rawPath); | ||
if (this.#watchers.has(resolved)) { | ||
@@ -243,3 +270,3 @@ log(`${resolved}: already watching`); | ||
for (const rawPath of paths) { | ||
const resolved = path.resolve(rawPath); | ||
const resolved = import_path.default.resolve(rawPath); | ||
log(`${resolved}: unwatching...`); | ||
@@ -256,5 +283,6 @@ this.#watchers.get(resolved)?.dispose(); | ||
}; | ||
export { | ||
// Annotate the CommonJS export names for ESM import in node: | ||
0 && (module.exports = { | ||
Watcher | ||
}; | ||
}); | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@miniflare/watcher", | ||
"version": "2.0.0-rc.3", | ||
"version": "2.0.0-rc.4", | ||
"description": "File-system watcher module for Miniflare: a fun, full-featured, fully-local simulator for Cloudflare Workers", | ||
@@ -14,4 +14,3 @@ "keywords": [ | ||
"license": "MIT", | ||
"type": "module", | ||
"exports": "./dist/src/index.js", | ||
"main": "./dist/src/index.js", | ||
"types": "./dist/src/index.d.ts", | ||
@@ -40,7 +39,7 @@ "files": [ | ||
"dependencies": { | ||
"@miniflare/shared": "2.0.0-rc.3" | ||
"@miniflare/shared": "2.0.0-rc.4" | ||
}, | ||
"devDependencies": { | ||
"@miniflare/shared-test": "2.0.0-rc.3" | ||
"@miniflare/shared-test": "2.0.0-rc.4" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
15717
287
No
+ Added@miniflare/shared@2.0.0-rc.4(transitive)
- Removed@miniflare/shared@2.0.0-rc.3(transitive)
Updated@miniflare/shared@2.0.0-rc.4