Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

machine-as-script

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

machine-as-script

Run a machine as a command-line script.

  • 1.0.4
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
8
increased by100%
Maintainers
1
Weekly downloads
 
Created
Source

machine-as-script

Build a modified version of a machine that proxies its inputs from CLI arguments and/or -- opts.

$ npm install machine-as-script --save

Usage

#!/usr/bin/env node

var asScript = require('machine-as-script');
var MPMath = require('machinepack-math');

asScript(MPMath.add).exec({
  success: function (sum){
    console.log('Got result:', sum);
  }
});

Now you can run your machine as a script and provide inputs as CLI opts:

$ node ./add-numbers.js --a=4 --b=5
# Got result: 9

Note that the machine definition you provide here doesn't have to come from an already-published machinepack-- it can be required locally from your project, or declared inline.

Using serial CLI arguments

You can use the args input to accept serial CLI arguments:

asScript({
  machine: MPMath.add,
  args: ['a', 'b']
}).exec({
  success: function (sum){
    console.log('Got result:', sum);
  }
});

Now you can use serial CLI arguments as inputs:

$ node ./add-numbers.js 2 3
# Got result: 5

License

MIT © Mike McNeil

Keywords

FAQs

Package last updated on 13 Jul 2015

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