Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@poppinss/utils

Package Overview
Dependencies
Maintainers
1
Versions
89
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@poppinss/utils - npm Package Compare versions

Comparing version 2.5.2 to 2.5.3

build/src/resolveDir.d.ts

1

build/index.d.ts

@@ -8,2 +8,3 @@ export { base64 } from './src/base64';

export { fsReadAll } from './src/fsReadAll';
export { resolveDir } from './src/resolveDir';
export { requireAll } from './src/requireAll';

@@ -10,0 +11,0 @@ export { esmRequire } from './src/esmRequire';

@@ -44,2 +44,4 @@ "use strict";

Object.defineProperty(exports, "fsReadAll", { enumerable: true, get: function () { return fsReadAll_1.fsReadAll; } });
var resolveDir_1 = require("./src/resolveDir");
Object.defineProperty(exports, "resolveDir", { enumerable: true, get: function () { return resolveDir_1.resolveDir; } });
var requireAll_1 = require("./src/requireAll");

@@ -46,0 +48,0 @@ Object.defineProperty(exports, "requireAll", { enumerable: true, get: function () { return requireAll_1.requireAll; } });

12

package.json
{
"name": "@poppinss/utils",
"version": "2.5.2",
"version": "2.5.3",
"description": "Handy utilities for repetitive work",

@@ -34,5 +34,5 @@ "main": "build/index.js",

"@adonisjs/mrm-preset": "^2.4.0",
"@poppinss/dev-utils": "^1.0.7",
"@poppinss/dev-utils": "^1.0.8",
"@types/ms": "^0.7.31",
"@types/node": "^14.0.23",
"@types/node": "^14.0.27",
"commitizen": "^4.1.2",

@@ -42,3 +42,3 @@ "cz-conventional-changelog": "^3.2.0",

"doctoc": "^1.4.0",
"eslint": "^7.4.0",
"eslint": "^7.6.0",
"eslint-config-prettier": "^6.11.0",

@@ -52,4 +52,4 @@ "eslint-plugin-adonis": "^1.0.14",

"mrm": "^2.3.3",
"np": "^6.3.2",
"npm-audit-html": "^1.4.1",
"np": "^6.4.0",
"npm-audit-html": "^1.4.3",
"prettier": "^2.0.5",

@@ -56,0 +56,0 @@ "ts-node": "^8.10.2",

@@ -21,2 +21,3 @@ <div align="center"><img src="https://res.cloudinary.com/adonisjs/image/upload/q_100/v1557762307/poppinss_iftxlt.jpg" width="600px"></div>

- [resolveFrom](#resolvefrom)
- [resolveDir](#resolvedir)
- [interpolate](#interpolate)

@@ -163,2 +164,26 @@ - [Lodash utilities](#lodash-utilities)

## resolveDir
The `require.resolve` or `resolveFrom` method can only resolve paths to a given file and not the directory. For example: If you pass path to a directory, then it will search for `index.js` inside it and in case of a package, it will be search for `main` entry point.
On the other hand, the `resolveDir` method can also resolve path to directories using following resolution.
- Absolute paths are returned as it is.
- Relative paths starting with `./` or `.\` are resolved using `path.join`.
- Path to packages inside `node_modules` are resolved as follows:
- Uses `require.resolve` to resolve the `package.json` file.
- Then replace the `package-name` with the absolute resolved package path.
```ts
import { resolveDir } from '@poppinss/utils'
resolveDir(__dirname, './database/migrations')
// __dirname + /database/migrations
resolveDir(__dirname, 'some-package/database/migrations')
// {path-to-package}/database/migrations
resolveDir(__dirname, '@some/package/database/migrations')
// {path-to-package}/database/migrations
```
## interpolate

@@ -165,0 +190,0 @@ A small utility function to interpolate values inside a string.

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