New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

scriptenv

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

scriptenv

Create an object hierarchy of functions from a directory structure

latest
Source
npmnpm
Version
0.1.2
Version published
Maintainers
1
Created
Source

ScriptEnv

Create an object hierarchy of functions from a directory structure containing plain .js files. Useful for creating sharable JavaScript libraries from separate components.

Description

An object is created for each directory. Symlinks are included as they are and the last function of each file is added to the resulting object named as the file name.

Usage: scriptenv <dirname> [options]

  --nowrap            don't wrap each file in a closure
  --scope <scopeVar>  name of the variable the closure should be applied to
  --exclude <regExp>  exclude files/dirs matching
  --closure           use obj["prop"] to allow use of the closure compiler

Example

Given a directory like this (the test directory):

test
├── bar
│   ├── apple.js
│   └── tomato.js
├── deep
│   └── a
│       └── b
│           └── c
│               └── d
│                   └── fish.js
└── foo.js

Running

scriptenv test

Will print a closure that creates a structure like this:

{ foo: [Function: foo_$yes],
  bar: { apple: [Function: apple], tomato: [Function: tomato] },
  deep: { a: { b: { c: { d: { fish: [Function: fishDeepInTheSea] } } } } } }

where each function in the resulting object is named as the file it resides in.

It is also possible to require a scriptenv dir in node:

var myScriptEnv = require('scriptenv')('myScriptEnvDir', {
    exclude: /deep/,
    nowrap: true
});

Keywords

javascript

FAQs

Package last updated on 02 May 2014

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