Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// The plugins.js file needs to be recreated
// when we delete either the admin folder
// the admin/src folder
// or the plugins.js file
// since the path are different when developing inside the monorepository or inside an app
const shouldCopyPluginsJSFile =
filePath.split('/admin/src').filter(p => !!p).length === 1;
if (
(event === 'unlinkDir' &&
!isExtension &&
shouldCopyPluginsJSFile) ||
(!isExtension && filePath.includes('plugins.js'))
) {
await strapiAdmin.createPluginsJs(
appPlugins,
path.join(cacheDir)
);
}
} catch (err) {
// Do nothing
}
}
} else {
// In any other case just copy the file into the .cache folder
try {
await fs.copy(filePath, path.join(destFolder, targetPath));
} catch (err) {
console.log(err);
}
}