🔀 Merge branch 'master' into oauth-support

This commit is contained in:
Jan Oberhauser
2020-06-04 09:44:21 +02:00
4 changed files with 24 additions and 20 deletions

View File

@@ -97,24 +97,28 @@ class LoadNodesAndCredentialsClass {
* @memberof LoadNodesAndCredentialsClass
*/
async getN8nNodePackages(): Promise<string[]> {
const packages: string[] = [];
for (const file of await fsReaddirAsync(this.nodeModulesPath)) {
if (file.indexOf('n8n-nodes-') !== 0) {
continue;
const getN8nNodePackagesRecursive = async (relativePath: string): Promise<string[]> => {
const results: string[] = [];
const nodeModulesPath = `${this.nodeModulesPath}/${relativePath}`;
for (const file of await fsReaddirAsync(nodeModulesPath)) {
const isN8nNodesPackage = file.indexOf('n8n-nodes-') === 0;
const isNpmScopedPackage = file.indexOf('@') === 0;
if (!isN8nNodesPackage && !isNpmScopedPackage) {
continue;
}
if (!(await fsStatAsync(nodeModulesPath)).isDirectory()) {
continue;
}
if (isN8nNodesPackage) { results.push(`${relativePath}${file}`); }
if (isNpmScopedPackage) {
results.push(...await getN8nNodePackagesRecursive(`${relativePath}${file}/`));
}
}
// Check if it is really a folder
if (!(await fsStatAsync(path.join(this.nodeModulesPath, file))).isDirectory()) {
continue;
}
packages.push(file);
}
return packages;
return results;
};
return getN8nNodePackagesRecursive('');
}
/**
* Loads credentials from a file
*