parent-module

WebJar for parent-module

License

License

MIT
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

parent-module
Last Version

Last Version

1.0.1
Release Date

Release Date

Type

Type

jar
Description

Description

parent-module
WebJar for parent-module
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/sindresorhus/parent-module

Download parent-module

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/parent-module/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>parent-module</artifactId>
    <version>1.0.1</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/parent-module/
implementation 'org.webjars.npm:parent-module:1.0.1'
// https://jarcasting.com/artifacts/org.webjars.npm/parent-module/
implementation ("org.webjars.npm:parent-module:1.0.1")
'org.webjars.npm:parent-module:jar:1.0.1'
<dependency org="org.webjars.npm" name="parent-module" rev="1.0.1">
  <artifact name="parent-module" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='parent-module', version='1.0.1')
)
libraryDependencies += "org.webjars.npm" % "parent-module" % "1.0.1"
[org.webjars.npm/parent-module "1.0.1"]

Dependencies

compile (1)

Group / Artifact Type Version
org.webjars.npm : callsites jar [3.0.0,4)

Project Modules

There are no modules declared in this project.

parent-module Build Status

Get the path of the parent module

Node.js exposes module.parent, but it only gives you the first cached parent, which is not necessarily the actual parent.

Install

$ npm install parent-module

Usage

// bar.js
const parentModule = require('parent-module');

module.exports = () => {
	console.log(parentModule());
	//=> '/Users/sindresorhus/dev/unicorn/foo.js'
};
// foo.js
const bar = require('./bar');

bar();

API

parentModule(filePath?)

By default, it will return the path of the immediate parent.

filePath

Type: string
Default: __filename

File path of the module of which to get the parent path.

Useful if you want it to work multiple module levels down.

Tip

Combine it with read-pkg-up to read the package.json of the parent module.

const path = require('path');
const readPkgUp = require('read-pkg-up');
const parentModule = require('parent-module');

console.log(readPkgUp.sync({cwd: path.dirname(parentModule())}).pkg);
//=> {name: 'chalk', version: '1.0.0', …}

Get professional support for this package with a Tidelift subscription
Tidelift helps make open source sustainable for maintainers while giving companies
assurances about security, maintenance, and licensing for their dependencies.

Versions

Version
1.0.1