mirror of
https://github.com/gabehf/Tdarr_Plugins.git
synced 2026-03-10 16:00:28 -07:00
Ensure all requires are within plugin functions
This commit is contained in:
parent
30e9ae1b9b
commit
69e04a5c1f
7 changed files with 29 additions and 23 deletions
|
|
@ -69,6 +69,23 @@ module.exports.plugin = plugin;`;
|
|||
process.exit(1);
|
||||
}
|
||||
|
||||
// check deps are within functions
|
||||
const keyWord = 'require(';
|
||||
const requires = read.split(keyWord);
|
||||
|
||||
if (requires.length >= 2) {
|
||||
const allBefore = [];
|
||||
for (let j = 0; j < requires.length - 1; j += 1) {
|
||||
allBefore.push(requires[j]);
|
||||
const countOpen = allBefore.join(keyWord).split('{').length - 1;
|
||||
const countClose = allBefore.join(keyWord).split('}').length - 1;
|
||||
if (countOpen === countClose) {
|
||||
console.log(`Plugin has requires outside of function '${folder}/${files[i]}'`);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let pluginDetails;
|
||||
try {
|
||||
// eslint-disable-next-line import/no-dynamic-require,global-require
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue