MCPcopy Index your code
hub / github.com/clns/node-commit-msg / getPackageJsonConfig

Function getPackageJsonConfig

lib/commit-message.js:77–93  ·  view source on GitHub ↗
(dir)

Source from the content-addressed store, hash-verified

75// use the 'commitMsg' key from it, if any.
76CommitMessage.resolveConfig = function(cfg, cb) {
77 var getPackageJsonConfig = function(dir) {
78 if (!dir) {
79 return cb(false);
80 }
81 var file = path.resolve(dir, 'package.json');
82 // check if exists, not with fs.exists() since it's deprecated
83 fs.open(file, 'r', function(err, fd) {
84 if (!err) {
85 var pkg = require(file);
86 cb(pkg.commitMsg);
87 fs.close(fd);
88 } else {
89 var upDir = path.resolve(dir, '..');
90 getPackageJsonConfig(upDir != dir ? upDir : null);
91 }
92 });
93 }
94 if (cfg && typeof(cfg) != 'object') {
95 // try to find the first package.json file with a config
96 getPackageJsonConfig(typeof(cfg) == 'string' ? cfg : __dirname);

Callers 1

commit-message.jsFile · 0.85

Calls 1

cbFunction · 0.85

Tested by

no test coverage detected