New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

code-dir

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

code-dir

Find the parent directory for top level projects.

latest
Source
npmnpm
Version
0.3.0
Version published
Maintainers
1
Created
Source

code-dir Build status for code-dir on Circle CI.

Find the parent directory for top level projects.

Why?

  • Simple downward search algorithm.
  • Useful for operating on multiple projects.
  • The end user likely visits here a lot.

Install

npm install code-dir --save

Usage

Get it into your program.

const codeDir = require('code-dir');

Find the directory where the end user stores their projects.

codeDir().then((dirPath) => {
    console.log(dirPath);  // => '/Users/sholladay/Code/personal'
});

API

codeDir(cwd)

Returns a Promise for the path of the topmost project's parent directory. A project is a directory that contains either .git or package.json.

cwd

Type: string
Default: process.cwd()

Current working directory the search is based on. This is the deepest directory that could be returned. If neither it nor any of its parent directories are projects, then as a last resort, its children are checked to determine if any of them are projects, in case the working directory itself is the code directory, since that is a common case.

Contributing

See our contributing guidelines for more details.

  • Fork it.
  • Make a feature branch: git checkout -b my-new-feature
  • Commit your changes: git commit -am 'Add some feature'
  • Push to the branch: git push origin my-new-feature
  • Submit a pull request.

License

MPL-2.0 © Seth Holladay

Go make something, dang it.

Keywords

package

FAQs

Package last updated on 16 Aug 2017

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