@homer0/root-file
TypeScript icon, indicating that this package has built-in type declarations

3.0.4 • Public • Published

⚓️ Root file

Import or require a file for the project root.

🍿 Usage

⚠️ This package is only for Node.

⚙️ Example

import { rootFile } from '@homer0/root-file';

const root = rootFile();

// ...

const info = await root.import('some-file.js');
// or
const info = root.require('some-file.js');

Jimple provider

If your app uses a Jimple container, you can register RootFile as the rootFile service by using its provider:

import { rootFileProvider } from '@homer0/root-file';

// ...

container.register(rootFileProvider);

// ...

const env = container.get('rootFile');

And since the provider is a "provider creator" (created with my custom version of Jimple), you can customize its service name:

container.register(
  rootFileProvider({
    serviceName: 'myRootFile',
  }),
);
Dependencies

RootFile depends on the following services, and when used with Jimple, it will try to find them in the container, otherwise, it will create new instances:

  • @homer0/path-utils, with the name pathUtils. Used to generate the paths relative to the project root.

If you already implement the dependencies, but with a different name, you can specify them in the provider:

container.register(
  rootFileProvider({
    services: {
      pathUtils: 'myPathUtils',
    },
  }),
);

🤘 Development

As this project is part of the packages monorepo, some of the tooling, like lint-staged and husky, are installed on the root's package.json.

Tasks

Task Description
lint Lints the package.
test Runs the unit tests.
build Transpiles the project.
types:check Validates the TypeScript types.

Package Sidebar

Install

npm i @homer0/root-file

Weekly Downloads

0

Version

3.0.4

License

MIT

Unpacked Size

24.9 kB

Total Files

10

Last publish

Collaborators

  • homer0