🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

rosid-handler-node

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rosid-handler-node

Load JS and transform to HTML

Source
npmnpm
Version
2.1.0
Version published
Weekly downloads
10
-79.17%
Maintainers
1
Weekly downloads
 
Created
Source

rosid-handler-node

Travis Build Status Coverage Status Dependencies

A function that loads a JS file and transforms it to HTML by executing the exported default function.

Install

npm install rosid-handler-node

Usage

const node = require('rosid-handler-node')

node('/src/index.js', '/src', '/dist', {}).then(({ data, savePath }) => {})
node('/src/index.html', '/src', '/dist', {}).then(({ data, savePath }) => {})
node('/src/index.xml', '/src', '/dist', { args: { fileExt: 'xml' } }).then(({ data, savePath }) => {})
node('/src/index.js', '/src', '/dist', { args: { saveExt: 'xml' } }).then(({ data, savePath }) => {})

Example

Add the following object to your rosidfile.json, rosidfile.js or routes array. rosid-handler-node will execute all matching JS files in your source folder and save the output as static HTML.

{
	"name"    : "Node",
	"path"    : "[^_]*.{html,js}*",
	"handler" : "rosid-handler-node"
}
// index.js
export default () => '<h1>Hello World</h1>'
<!-- index.html (output) -->
<h1>Hello World</h1>

Parameters

  • filePath {String} Absolute path to the requested file.
  • srcPath {String} Absolute path to the source folder.
  • distPath {?String} Absolute path to the export folder.
  • route {Object} The route which matched the request URL.

Returns

  • {Promise}({Object})
    • data {String | Buffer} The transformed file content.
    • savePath {?String} Where to save the file when compiling.

Keywords

rosid

FAQs

Package last updated on 15 Jan 2017

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