New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

hardcode

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hardcode

Assembles a virtual, `import`-able file system from disk.

  • 1.4.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
23
increased by666.67%
Maintainers
1
Weekly downloads
 
Created
Source

hardcode

hardcode assembles a virtual, import-able file system from disk.

Install

npm i hardcode

CLI

The package comes with a built-in CLI for build scripts:

hardcode <glob> --out <out> --prefix <prefix>

See hardcode --help for more details.

Add hardcode <glob> to your build script. For example:

...
"build": "hardcode <pattern> && jest"
...

Usage

  1. Imagine that you have the following files on disk:
templates/
 dev/
  email.html
   res/
    style.css
  1. Now, run hardcode on the templates/dev directory.
const hardcode = require('hardcode');

hardcode({
	pattern: 'templates/dev/**',
	prefix: 'templates/dev/',
	out: 'templates/import/'
});
  1. Finally, import the templates/dev directory as a JSON object:
const templates = require('./templates/import')

const html = templates['email.html'] // email.html file contents
const css = templates['res']['style.css'] // style.css file contents

License

This code is licensed under GNU-GPLv3.

Keywords

FAQs

Package last updated on 24 Nov 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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