Skip to content

Commit 7a03c44

Browse files
authored
Merge pull request #18 from constructive-io/find-and-require-package
Find and require package
2 parents 3e7186a + 4a0aaba commit 7a03c44

File tree

15 files changed

+2541
-5142
lines changed

15 files changed

+2541
-5142
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ jobs:
4949
- appstash
5050
- clean-ansi
5151
- fetch-api-client
52-
- find-pkg
52+
- find-and-require-package-json
5353
- http-errors
5454
- jsonld-tools
5555
- komoji

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ A comprehensive collection of TypeScript utilities for working with schemas, JSO
3131
| **strfy-js** | [![npm](https://img.shields.io/npm/v/strfy-js.svg)](https://www.npmjs.com/package/strfy-js) | [GitHub](./packages/strfy-js) | Stringify JSON as JavaScript with extended serialization capabilities |
3232
| **yanse** | [![npm](https://img.shields.io/npm/v/yanse.svg)](https://www.npmjs.com/package/yanse) | [GitHub](./packages/yanse) | Fast and lightweight terminal color styling library with chalk-like API |
3333
| **@interweb/fetch-api-client** | [![npm](https://img.shields.io/npm/v/@interweb/fetch-api-client.svg)](https://www.npmjs.com/package/@interweb/fetch-api-client) | [GitHub](./packages/fetch-api-client) | Universal Fetch-based HTTP client for Node.js and browsers |
34-
| **@interweb/find-pkg** | [![npm](https://img.shields.io/npm/v/@interweb/find-pkg.svg)](https://www.npmjs.com/package/@interweb/find-pkg) | [GitHub](./packages/find-pkg) | Find the package.json file from within a build/package |
34+
| **find-and-require-package-json** | [![npm](https://img.shields.io/npm/v/find-and-require-package-json.svg)](https://www.npmjs.com/package/find-and-require-package-json) | [GitHub](./packages/find-and-require-package-json) | Find the package.json file from within a build/package |
3535
| **@interweb/http-errors** | [![npm](https://img.shields.io/npm/v/@interweb/http-errors.svg)](https://www.npmjs.com/package/@interweb/http-errors) | [GitHub](./packages/http-errors) | HTTP error handling utilities for API clients |
3636
| **@interweb/node-api-client** | [![npm](https://img.shields.io/npm/v/@interweb/node-api-client.svg)](https://www.npmjs.com/package/@interweb/node-api-client) | [GitHub](./packages/node-api-client) | Lightweight HTTP client for Node.js RESTful APIs |
3737
| **@schema-typescript/cli** | [![npm](https://img.shields.io/npm/v/@schema-typescript/cli.svg)](https://www.npmjs.com/package/@schema-typescript/cli) | [GitHub](./packages/schema-ts-cli) | schema-typescript CLI |

packages/find-pkg/CHANGELOG.md renamed to packages/find-and-require-package-json/CHANGELOG.md

File renamed without changes.

packages/find-pkg/README.md renamed to packages/find-and-require-package-json/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# @interweb-utils/find-pkg
1+
# find-and-require-package-json
22

33
<p align="center">
44
<img src="https://raw.githubusercontent.com/hyperweb-io/dev-utils/refs/heads/main/docs/img/logo.svg" width="80">
@@ -18,15 +18,15 @@ This TypeScript module provides a function to locate, read, and parse the `packa
1818
## install
1919

2020
```sh
21-
npm install @interweb-utils/find-pkg
21+
npm install find-and-require-package-json
2222
```
2323

2424
### Example
2525

2626
```js
27-
import { findPackageJson } from '@interweb-utils/find-pkg';
27+
import { findAndRequirePackageJson } from 'find-and-require-package-json';
2828

29-
const packageJson = findPackageJson();
29+
const packageJson = findAndRequirePackageJson();
3030
console.log('Package name:', packageJson.name);
3131
console.log('Version:', packageJson.version);
3232
```

packages/find-pkg/__tests__/find-pkg.test.ts renamed to packages/find-and-require-package-json/__tests__/find-pkg.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import { existsSync, readFileSync } from 'fs';
22
import { dirname, join } from 'path';
33

4-
import { findPackageJson } from '../src';
4+
import { findAndRequirePackageJson } from '../src';
55

66
// Mock dependencies
77
jest.mock('fs');
88
jest.mock('path');
99

10-
describe('findPackageJson', () => {
10+
describe('findAndRequirePackageJson', () => {
1111
const mockPackageJson = {
1212
name: 'mock-package',
1313
version: '1.0.0',
@@ -38,7 +38,7 @@ describe('findPackageJson', () => {
3838

3939
jest.spyOn(process, 'cwd').mockReturnValue(mockCurrentDir);
4040

41-
const result = findPackageJson();
41+
const result = findAndRequirePackageJson();
4242

4343
expect(result).toEqual(mockPackageJson);
4444
expect(existsSync).toHaveBeenCalledWith(mockFilePath);
@@ -57,7 +57,7 @@ describe('findPackageJson', () => {
5757

5858
jest.spyOn(process, 'cwd').mockReturnValue(mockCurrentDir);
5959

60-
expect(() => findPackageJson()).toThrow(
60+
expect(() => findAndRequirePackageJson()).toThrow(
6161
'package.json not found in any parent directory'
6262
);
6363
expect(existsSync).toHaveBeenCalledWith(mockFilePath);

packages/find-pkg/jest.config.js renamed to packages/find-and-require-package-json/jest.config.js

File renamed without changes.

packages/find-pkg/package.json renamed to packages/find-and-require-package-json/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "@interweb/find-pkg",
2+
"name": "find-and-require-package-json",
33
"version": "0.6.7",
44
"author": "Dan Lynch <[email protected]>",
55
"description": "Find the package.json file from within a build/package",

packages/find-pkg/src/index.ts renamed to packages/find-and-require-package-json/src/index.ts

File renamed without changes.

packages/find-pkg/src/package.ts renamed to packages/find-and-require-package-json/src/package.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ function _findPackageJson(currentDir: string): string {
3636
return _findPackageJson(parentDir);
3737
}
3838

39-
export function findPackageJson(): PackageJson {
39+
export function findAndRequirePackageJson(): PackageJson {
4040
// Start searching from the current directory
4141
const pkgPath = _findPackageJson(__dirname);
4242

packages/find-pkg/tsconfig.esm.json renamed to packages/find-and-require-package-json/tsconfig.esm.json

File renamed without changes.

0 commit comments

Comments
 (0)