pax_global_header00006660000000000000000000000064134620424460014517gustar00rootroot0000000000000052 comment=55afe697667744f61fd78787526d6c4d989d75fc resolve-cwd-3.0.0/000077500000000000000000000000001346204244600137515ustar00rootroot00000000000000resolve-cwd-3.0.0/.editorconfig000066400000000000000000000002571346204244600164320ustar00rootroot00000000000000root = true [*] indent_style = tab end_of_line = lf charset = utf-8 trim_trailing_whitespace = true insert_final_newline = true [*.yml] indent_style = space indent_size = 2 resolve-cwd-3.0.0/.gitattributes000066400000000000000000000000231346204244600166370ustar00rootroot00000000000000* text=auto eol=lf resolve-cwd-3.0.0/.gitignore000066400000000000000000000000271346204244600157400ustar00rootroot00000000000000node_modules yarn.lock resolve-cwd-3.0.0/.npmrc000066400000000000000000000000231346204244600150640ustar00rootroot00000000000000package-lock=false resolve-cwd-3.0.0/.travis.yml000066400000000000000000000000651346204244600160630ustar00rootroot00000000000000language: node_js node_js: - '12' - '10' - '8' resolve-cwd-3.0.0/fixture/000077500000000000000000000000001346204244600154375ustar00rootroot00000000000000resolve-cwd-3.0.0/fixture/fixture.js000066400000000000000000000000001346204244600174510ustar00rootroot00000000000000resolve-cwd-3.0.0/index.d.ts000066400000000000000000000024401346204244600156520ustar00rootroot00000000000000declare const resolveCwd: { /** Resolve the path of a module like [`require.resolve()`](https://nodejs.org/api/globals.html#globals_require_resolve) but from the current working directory. @param moduleId - What you would use in `require()`. @returns The resolved module path. @throws When the module can't be found. @example ``` import resolveCwd = require('resolve-cwd'); console.log(__dirname); //=> '/Users/sindresorhus/rainbow' console.log(process.cwd()); //=> '/Users/sindresorhus/unicorn' console.log(resolveCwd('./foo')); //=> '/Users/sindresorhus/unicorn/foo.js' ``` */ (moduleId: string): string; /** Resolve the path of a module like [`require.resolve()`](https://nodejs.org/api/globals.html#globals_require_resolve) but from the current working directory. @param moduleId - What you would use in `require()`. @returns The resolved module path. Returns `undefined` instead of throwing when the module can't be found. @example ``` import resolveCwd = require('resolve-cwd'); console.log(__dirname); //=> '/Users/sindresorhus/rainbow' console.log(process.cwd()); //=> '/Users/sindresorhus/unicorn' console.log(resolveCwd.silent('./foo')); //=> '/Users/sindresorhus/unicorn/foo.js' ``` */ silent(moduleId: string): string | undefined; }; export = resolveCwd; resolve-cwd-3.0.0/index.js000066400000000000000000000003201346204244600154110ustar00rootroot00000000000000'use strict'; const resolveFrom = require('resolve-from'); module.exports = moduleId => resolveFrom(process.cwd(), moduleId); module.exports.silent = moduleId => resolveFrom.silent(process.cwd(), moduleId); resolve-cwd-3.0.0/index.test-d.ts000066400000000000000000000002501346204244600166240ustar00rootroot00000000000000import {expectType} from 'tsd'; import resolveCwd = require('.'); expectType(resolveCwd('./foo')); expectType(resolveCwd.silent('./foo')); resolve-cwd-3.0.0/license000066400000000000000000000021251346204244600153160ustar00rootroot00000000000000MIT License Copyright (c) Sindre Sorhus (sindresorhus.com) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. resolve-cwd-3.0.0/package.json000066400000000000000000000013411346204244600162360ustar00rootroot00000000000000{ "name": "resolve-cwd", "version": "3.0.0", "description": "Resolve the path of a module like `require.resolve()` but from the current working directory", "license": "MIT", "repository": "sindresorhus/resolve-cwd", "author": { "name": "Sindre Sorhus", "email": "sindresorhus@gmail.com", "url": "sindresorhus.com" }, "engines": { "node": ">=8" }, "scripts": { "test": "xo && ava && tsd" }, "files": [ "index.js", "index.d.ts" ], "keywords": [ "require", "resolve", "path", "module", "from", "like", "cwd", "current", "working", "directory", "import" ], "dependencies": { "resolve-from": "^5.0.0" }, "devDependencies": { "ava": "^1.4.1", "tsd": "^0.7.2", "xo": "^0.24.0" } } resolve-cwd-3.0.0/readme.md000066400000000000000000000031221346204244600155260ustar00rootroot00000000000000# resolve-cwd [![Build Status](https://travis-ci.org/sindresorhus/resolve-cwd.svg?branch=master)](https://travis-ci.org/sindresorhus/resolve-cwd) > Resolve the path of a module like [`require.resolve()`](https://nodejs.org/api/globals.html#globals_require_resolve) but from the current working directory ## Install ``` $ npm install resolve-cwd ``` ## Usage ```js const resolveCwd = require('resolve-cwd'); console.log(__dirname); //=> '/Users/sindresorhus/rainbow' console.log(process.cwd()); //=> '/Users/sindresorhus/unicorn' console.log(resolveCwd('./foo')); //=> '/Users/sindresorhus/unicorn/foo.js' ``` ## API ### resolveCwd(moduleId) Like `require()`, throws when the module can't be found. ### resolveCwd.silent(moduleId) Returns `undefined` instead of throwing when the module can't be found. #### moduleId Type: `string` What you would use in `require()`. ## Related - [resolve-from](https://github.com/sindresorhus/resolve-from) - Resolve the path of a module from a given path - [import-from](https://github.com/sindresorhus/import-from) - Import a module from a given path - [import-cwd](https://github.com/sindresorhus/import-cwd) - Import a module from the current working directory - [resolve-pkg](https://github.com/sindresorhus/resolve-pkg) - Resolve the path of a package regardless of it having an entry point - [import-lazy](https://github.com/sindresorhus/import-lazy) - Import a module lazily - [resolve-global](https://github.com/sindresorhus/resolve-global) - Resolve the path of a globally installed module ## License MIT © [Sindre Sorhus](https://sindresorhus.com) resolve-cwd-3.0.0/test.js000066400000000000000000000006031346204244600152650ustar00rootroot00000000000000import test from 'ava'; import resolveCwd from '.'; process.chdir('fixture'); test('resolveCwd()', t => { t.regex(resolveCwd('./fixture'), /fixture\/fixture\.js$/); t.throws(() => { resolveCwd('./nonexistent'); }); }); test('resolveCwd.silent()', t => { t.regex(resolveCwd.silent('./fixture'), /fixture\/fixture\.js$/); t.is(resolveCwd.silent('./nonexistent'), undefined); });