npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

node-fire

v0.2.7

Published

Run a js object or a function by command line directly.

Downloads

47

Readme

node-fire

Run a js object, Promise, Generator or a function by command line directly.

Install

$ npm install -g node-fire

How to use

$ fire ./test.js arg1 arg2 name=john

Fire third party node modules

> npm install md5
> fire md5 test
> npm install uuid
> fire uuid
> npm install open
> fire open http://127.0.0.1
...

More Example

Fire remote js

curl https://raw.githubusercontent.com/lwdgit/node-fire/dev/examples/calc.js | fire add 1 2

Fire local

Test1

```
//test.js
module.exports = function(arg1, arg2) {
    console.log(arg1, Array.isArray(arg1));
    console.log(arg2);
    console.log(this.arg3);
    console.log(this.arg4);
    return 'done';
}
```
RUN
```
fire ./test.js "1,2,3,4" hello --arg3 world --arg4 "the end"
```
Output:

```
[ '1', '2', '3', '4' ] true
hello
world
the end
done
```

Test2

//test2.js
module.exports = function (a, opts, c) {
  return `${a} ${opts.name}${c}`
}

RUN

fire ./test2.js hello name=world !

Output:

hello world!

One more

//calc.js
exports.add = function(a, b) {
    return a + b;
}

exports.multiply = function*(a, b) {
    return a * b;
}

exports.pow = function(a) {
    return a * a;
}
exports.div = function(a, b) {
    b = b || this.b;
    return a / b;
}

RUN

fire ./calc.js add 3 4                // 7
fire ./calc.js multiply 3 4           // 12
fire ./calc.js pow 3                  //9
fire examples/calc.js div 8 0 --b=2   //4         

As a wrapper

//wrap.js
const { wrap } = require('node-fire');
const calc = function(a, b) {
    return a + b;
}

wrap(calc)(process.argv)
.then(function (ret) {
    console.log(ret);
});
node ./wrap.js 3 4

As a npm scripts runner

//package.json
{
  "scripts": {
    "open": "fire open http://127.0.0.1",
    "copy": "fire shelljs cp package.json package.json2",
    "combo": "fire mathjs random 0 100 | xargs touch ",
    "math": "fire mathjs add 42423.321 32132"
  },
  "devDependencies": {
    "mathjs": "^3.9.3",
    "open": "^0.0.5",
    "shelljs": "^0.7.6",
    "node-fire": "latest"
  }
}

quick test:

mkdir quick_test && cd quick_test
cat << EOF > package.json
{
  "scripts": {
    "open": "fire open http://127.0.0.1",
    "copy": "fire shelljs cp ...package.json,package.json2",
    "combo": "fire mathjs random 0 100 | xargs touch ",
    "math": "fire mathjs add 42423.321 32132",
    "ls": "fire shelljs ls stdout"
  },
  "devDependencies": {
    "mathjs": "^3.9.3",
    "open": "^0.0.5",
    "shelljs": "^0.7.6",
    "node-fire": "latest"
  }
}
EOF

npm install
npm run math
npm run copy
npm run combo
npm run open

More usage please checkout tests

Debug

DEBUG=log fire xxx.js

Contribution

Fork

Issues

LICENSE

Under MIT license