{"id":20195842,"url":"https://github.com/ralphv/require-inject-scope","last_synced_at":"2026-05-11T15:42:39.024Z","repository":{"id":57354280,"uuid":"89126299","full_name":"ralphv/require-inject-scope","owner":"ralphv","description":"Inject scoped variables when requiring a file in Node.js","archived":false,"fork":false,"pushed_at":"2017-04-23T11:16:31.000Z","size":11,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-10-10T17:08:13.655Z","etag":null,"topics":["inject","nodejs","require","scope","variables"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ralphv.png","metadata":{"files":{"readme":"README.md","changelog":"ChangeLog","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-04-23T07:58:56.000Z","updated_at":"2018-04-27T23:48:37.000Z","dependencies_parsed_at":"2022-09-26T20:21:50.882Z","dependency_job_id":null,"html_url":"https://github.com/ralphv/require-inject-scope","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ralphv/require-inject-scope","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ralphv%2Frequire-inject-scope","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ralphv%2Frequire-inject-scope/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ralphv%2Frequire-inject-scope/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ralphv%2Frequire-inject-scope/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ralphv","download_url":"https://codeload.github.com/ralphv/require-inject-scope/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ralphv%2Frequire-inject-scope/sbom","scorecard":{"id":760488,"data":{"date":"2025-08-11","repo":{"name":"github.com/ralphv/require-inject-scope","commit":"b9c6d509c3f85d49a294942cc66633997f9fccf9"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3,"checks":[{"name":"Code-Review","score":0,"reason":"Found 0/12 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":9,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Warn: project license file does not contain an FSF or OSI license."],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}}]},"last_synced_at":"2025-08-22T23:19:05.370Z","repository_id":57354280,"created_at":"2025-08-22T23:19:05.371Z","updated_at":"2025-08-22T23:19:05.371Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32902247,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-10T13:40:02.631Z","status":"online","status_checked_at":"2026-05-11T02:00:05.975Z","response_time":120,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["inject","nodejs","require","scope","variables"],"created_at":"2024-11-14T04:19:22.687Z","updated_at":"2026-05-11T15:42:38.997Z","avatar_url":"https://github.com/ralphv.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"## require-inject-scope - Inject scoped variables when requiring a file.\n\n[![NPM](https://nodei.co/npm/require-inject-scope.png?mini=true)](https://nodei.co/npm/require-inject-scope/)\n\n[![Build Status](https://travis-ci.org/ralphv/require-inject-scope.svg?branch=master)](https://travis-ci.org/ralphv/require-inject-scope)\n[![Coverage Status](https://coveralls.io/repos/github/ralphv/require-inject-scope/badge.svg?branch=master)](https://coveralls.io/github/ralphv/require-inject-scope?branch=master)\n        \n* [What is it?](#what-is-it)\n* [Getting started](#getting-started)\n* [Usage](#usage)\n* [License](#License)\n* [Changelog](#Changelog)\n\n## What is it\n\nThe built in `require` of Node.js does not have a way to allow you to inject scoped variables. \nThe variables `module`, `exports`, `__dirname`, `__filename`... are available in the context of a required file but there is no easy way to provide your own variables. \n\nMany developers will revert to using either globally defined variables or using singleton variables like `globals`, but neither of these are best practices.\n\nThis library allows you to inject your own variables to the context of the required file.\n\n## Getting started\n\n    $ npm install --save require-inject-scope\n\n## Usage\n\nrequire this library as early as possible in your own code.\n\n```javascript\nrequire(\"require-inject-scope\");\n```\n\nrequire will work normally as expected.\n\nWhen you need to inject variables into a scope, instead of calling `require` with one parameter which \nis the `path`, you call it using an array with exactly two elements. \nThe first element is the standard `path` and the second element will be an object having properties as variable names to inject and their values.\n\nThis is most useful when creating a plugin architecture where you want to provide the plugins a list of defined variables without requiring your plugins to require them manually.\n\nexample:\n\n```javascript\nrequire([\"./sample.js\", {\"$config\":configObject, \"$helper\": helperObject}]);\n```\n\nThe file sample.js will have the two variables `$config` and `$helper` defined in its scope similar to the standard available variables.\n\n### License\n\nrequire-inject-scope is licensed under the [MIT](https://github.com/ralphv/require-inject-scope/raw/master/LICENSE).\n\n### Changelog\n\n* 1.0.0: Initial version\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fralphv%2Frequire-inject-scope","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fralphv%2Frequire-inject-scope","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fralphv%2Frequire-inject-scope/lists"}