Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const plugin: Plugin = (builder, options) => {
function handleTagsError(err: Error): void {
console.error(`Failed to process smart tags file '${tagsFile}': ${err.message}`);
}
const initialTagsJSON: JSONPgSmartTags = JSON5.parse(readFileSync(tagsFile, 'utf8'));
let tagsListener: null | ((current: Stats, previous: Stats) => void) = null;
const smartTagsPlugin = makeJSONPgSmartTagsPlugin(initialTagsJSON, updateJSON => {
if (tagsListener) {
unwatchFile(tagsFile, tagsListener);
tagsListener = null;
}
if (updateJSON) {
tagsListener = (_current, _previous): void => {
readFile(tagsFile, 'utf8', (err, data) => {
if (err) {
if (err['code'] === 'ENOENT') {
updateJSON(null);
} else {
handleTagsError(err);
}
return;
}
try {