From 40af7507de4decf51eed71e8119bf2f4a2e4c595 Mon Sep 17 00:00:00 2001 From: Marak Date: Mon, 4 Dec 2017 00:39:45 -0500 Subject: [PATCH] [api] [minor] Added localPath to service pkg * Useful for knowing location of service * Better default service name when missing pkg * Required to fix bigcompany/hook.io-sdk#14 --- lib/requireServiceSync.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/requireServiceSync.js b/lib/requireServiceSync.js index 3091283..0bd5f99 100644 --- a/lib/requireServiceSync.js +++ b/lib/requireServiceSync.js @@ -52,10 +52,13 @@ function loadService (p, type) { var pkg; if (type === "file") { + service.localPath = path.resolve(p); + service.name = p.replace(/\.[^/.]+$/, ""); } else { try { pkg = JSON.parse(fs.readFileSync(path.resolve(p) + "/package.json").toString()); service.pkg = pkg; + service.localPath = path.resolve(p) + "/" + pkg.main; } catch (err) { // pkg not available, dont use throw err;