New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

load-pkg

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

load-pkg

Loads the package.json from the root of the user's current project.

  • 3.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
44K
increased by17.8%
Maintainers
1
Weekly downloads
 
Created
Source

load-pkg NPM version Build Status Build Status

Loads the package.json from the root of the user's current project.

HEADS UP!

Breaking changes in v2.0. The main export is now a function that must be called. This is so that the package.json is lazily loaded when the function is called.

Install

Install with npm

$ npm i load-pkg --save

async usage

var loadPkg = require('load-pkg');

// get the package.json from the cwd
loadPkg(function(err, pkg) {
  console.log(pkg.name);
  //=> 'load-pkg'
});

// get the package.json from the specified directory
loadPkg('~/foo/bar', function(err, pkg) {
  console.log(pkg.name);
  //=> 'load-pkg'
});

sync usage

var pkg = require('load-pkg').sync(process.cwd());
console.log(pkg.name);
//=> 'load-pkg'

Specify the cwd or filepath to start from:

var pkg = require('load-pkg').sync('a/b/c');
console.log(pkg.name);
//=> 'foo'
  • cwd: Easily get the CWD (current working directory) of a project based on package.json, optionally starting… more | homepage
  • find-pkg: Find the first directory with a package.json, recursing up, starting with the given directory. | homepage
  • look-up: Faster drop-in replacement for find-up and findup-sync. | homepage

Running tests

Install dev dependencies:

$ npm i -d && npm test

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.

Author

Brian Woodward

License

Copyright © 2015 Brian Woodward Released under the MIT license.


This file was generated by verb on December 13, 2015.

Keywords

FAQs

Package last updated on 13 Dec 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc