@sapphire/plugin-hmr
Advanced tools
Comparing version 1.1.1 to 1.2.0-next.4692d34.0
import { WatchOptions } from 'chokidar'; | ||
export interface HMROptions extends WatchOptions { | ||
enabled?: boolean; | ||
silent?: boolean; | ||
} | ||
@@ -15,3 +16,3 @@ /** | ||
*/ | ||
export declare function start({ enabled, ...options }?: HMROptions): void; | ||
export declare function start({ enabled, silent, ...options }?: HMROptions): void; | ||
//# sourceMappingURL=hmr.d.ts.map |
@@ -17,17 +17,16 @@ "use strict"; | ||
*/ | ||
function start({ enabled = true, ...options } = { enabled: true }) { | ||
function start({ enabled = true, silent = false, ...options } = { enabled: true }) { | ||
// Do not enable plugin when enabled is false | ||
if (!enabled) | ||
return; | ||
framework_1.container.logger.info('[HMR-Plugin]: Enabled. Watching for piece changes.'); | ||
if (!silent) | ||
framework_1.container.logger.info('[HMR-Plugin]: Enabled. Watching for piece changes.'); | ||
for (const store of framework_1.container.stores.values()) { | ||
const deleteCb = handlePiecePathDelete.bind(null, store); | ||
const updateCb = handlePiecePathUpdate.bind(null, store); | ||
(0, chokidar_1.watch)([...store.paths], options) | ||
.on('change', updateCb) | ||
.on('unlink', deleteCb); | ||
.on('change', (path) => handlePiecePathUpdate(store, path, silent)) | ||
.on('unlink', (path) => handlePiecePathDelete(store, path, silent)); | ||
} | ||
} | ||
exports.start = start; | ||
async function handlePiecePathDelete(store, path) { | ||
async function handlePiecePathDelete(store, path, silent) { | ||
if (!store.strategy.filter(path)) | ||
@@ -40,3 +39,4 @@ return; | ||
await pieceToDelete.unload(); | ||
framework_1.container.logger.info(`[HMR-Plugin]: Unloaded ${pieceToDelete.name} piece from ${pieceToDelete.store.name} store.`); | ||
if (!silent) | ||
framework_1.container.logger.info(`[HMR-Plugin]: Unloaded ${pieceToDelete.name} piece from ${pieceToDelete.store.name} store.`); | ||
}); | ||
@@ -47,3 +47,3 @@ if ((0, framework_1.isErr)(result)) { | ||
} | ||
async function handlePiecePathUpdate(store, path) { | ||
async function handlePiecePathUpdate(store, path, silent) { | ||
if (!store.strategy.filter(path)) | ||
@@ -55,3 +55,4 @@ return; | ||
await pieceToUpdate.reload(); | ||
framework_1.container.logger.info(`[HMR-Plugin]: reloaded ${pieceToUpdate.name} piece from ${pieceToUpdate.store.name} store.`); | ||
if (!silent) | ||
framework_1.container.logger.info(`[HMR-Plugin]: reloaded ${pieceToUpdate.name} piece from ${pieceToUpdate.store.name} store.`); | ||
} | ||
@@ -65,3 +66,4 @@ else { | ||
const piecesLoadedStoreNames = piecesLoaded.map((piece) => piece.store.name); | ||
framework_1.container.logger.info(`[HMR-Plugin]: Loaded ${piecesLoadedNames.join(', ')} piece(s) from ${[...new Set(piecesLoadedStoreNames)].join(', ')} store(s).`); | ||
if (!silent) | ||
framework_1.container.logger.info(`[HMR-Plugin]: Loaded ${piecesLoadedNames.join(', ')} piece(s) from ${[...new Set(piecesLoadedStoreNames)].join(', ')} store(s).`); | ||
} | ||
@@ -68,0 +70,0 @@ }); |
{ | ||
"name": "@sapphire/plugin-hmr", | ||
"version": "1.1.1", | ||
"version": "1.2.0-next.4692d34.0", | ||
"description": "Plugin for @sapphire/framework for hot module reloading for pieces", | ||
@@ -68,3 +68,3 @@ "author": "@sapphire", | ||
}, | ||
"gitHead": "8efee8b0bbdbddb43bb1836346f2a91cf20f6274" | ||
"gitHead": "4692d3442c4bf85e1c46cc2c18da0a46f2c3de4f" | ||
} |
Sorry, the diff of this file is not supported yet
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
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
24367
137
1