import-cwd

WebJar for import-cwd

License

License

MIT
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

import-cwd
Last Version

Last Version

3.0.0
Release Date

Release Date

Type

Type

jar
Description

Description

import-cwd
WebJar for import-cwd
Project URL

Project URL

https://www.webjars.org
Source Code Management

Source Code Management

https://github.com/sindresorhus/import-cwd

Download import-cwd

How to add to project

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

Dependencies

compile (1)

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

Project Modules

There are no modules declared in this project.

import-cwd

Import a module like with require() but from the current working directory

Install

$ npm install import-cwd

Usage

const importCwd = require('import-cwd');

// Target module is at '/Users/sindresorhus/unicorn/foo.js'

console.log(__dirname);
//=> '/Users/sindresorhus/rainbow'

console.log(process.cwd());
//=> '/Users/sindresorhus/unicorn'

const foo = importCwd('./foo');

API

importCwd(moduleId)

Like require(), throws when the module can't be found.

importCwd.silent(moduleId)

Returns undefined instead of throwing when the module can't be found.

moduleId

Type: string

What you would use in require().

Related

  • import-from - Import a module from a given path
  • resolve-from - Resolve the path of a module from a given path
  • resolve-cwd - Resolve the path of a module from the current working directory
  • resolve-pkg - Resolve the path of a package regardless of it having an entry point
  • import-lazy - Import modules lazily
  • import-global - Import a globally installed module

License

MIT © Sindre Sorhus

Versions

Version
3.0.0
2.1.0