Created
March 8, 2016 10:07
-
-
Save davazp/07ee30c28831a94f272e to your computer and use it in GitHub Desktop.
Load main package.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
let findup = require('findup'); | |
let path = require('path'); | |
const PACKAGEFILE = 'package.json'; | |
module.exports = function() { | |
let mainfile = require.main.filename; | |
if (mainfile){ | |
try { | |
let basedir = findup.sync(mainfile, PACKAGEFILE); | |
return require(path.join(basedir, PACKAGEFILE)); | |
} catch(err){ | |
// ignore error for now | |
} | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment