Skip to content

Commit

Permalink
[api] [minor] Added localPath to service pkg
Browse files Browse the repository at this point in the history
  * Useful for knowing location of service
  * Better default service name when missing pkg
  * Required to fix stackvana/hook.io-sdk#14
  • Loading branch information
Marak committed Dec 4, 2017
1 parent 68ebdf8 commit 40af750
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/requireServiceSync.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 40af750

Please sign in to comment.