Skip to content
This repository has been archived by the owner on Jul 10, 2023. It is now read-only.

Commit

Permalink
add default path for modules
Browse files Browse the repository at this point in the history
  • Loading branch information
fatihaydilek committed Apr 20, 2020
1 parent 55bb889 commit 3d70505
Showing 1 changed file with 4 additions and 15 deletions.
19 changes: 4 additions & 15 deletions src/plugins/utils/Utils.ts
Expand Up @@ -246,28 +246,17 @@ class Utils {
return endpoint.split('.')[0];
}

static tryRequire(name: string, paths?: string[]): any {
static tryRequire(name: string, paths= ['/var/task'] ): any {
try {
let resolvedPath;
if (paths !== undefined) {
resolvedPath = customReq.resolve(name, { paths });
} else {
resolvedPath = customReq.resolve(name);
}
const resolvedPath = customReq.resolve(name, { paths });
return customReq(resolvedPath);
// tslint:disable-next-line:no-empty
} catch (err) {}
}

static getModuleInfo(name: string, paths?: string[]): any {
static getModuleInfo(name: string, paths = ['/var/task']): any {
try {
let modulePath;
if (paths !== undefined) {
modulePath = customReq.resolve(name, { paths });
} else {
modulePath = customReq.resolve(name);
}

const modulePath = customReq.resolve(name, { paths });
return parse(modulePath);
} catch (err) {
return {};
Expand Down

0 comments on commit 3d70505

Please sign in to comment.