1.0.1 • Published 7 years ago

node-jmake v1.0.1

Weekly downloads
-
License
ISC
Repository
gitlab
Last release
7 years ago

jmake

Purpose

Jmake is a simple tool meant to run custom JavaScript functions in an easy way.
By simply providing a Makefile.js file, you will be able to do everything you want.

Installation

Simply run npm i node-jmake -g to make the jmake command available globally.

Usage

The most basic usage is to have a file Makefile.js at the root of your project.
This Makefile.js have to export commands that will be available to jmake.

// Can be executed with `jmake hello`
exports.hello = () => {
    console.log("Hello, World!");
};

You can also return a promise if you need to do asynchronous stuff.

// Can be executed with `jmake asynchronous`
exports.asynchronous = () =>
    new Promise(resolve => resolve("Hello, World!")).then(hello => console.log(hello));

Of course, it works with async/await as well.

const delay = ms =>
    new Promise(resolve => {
        setTimeout(() => {
            resolve();
        }, ms);
    });

// Can be executed with `jmake await`
exports.await = async () => {
    await delay(1000);
    console.log("1s has passed!");
};

You can even get arguments from the command line.

exports.args = (arg1, arg2) => {
    console.log("arg1 -->", arg1);
    console.log("arg2 -->", arg2);
};
// $ jmake args hello world
// > arg1 --> hello
// > arg2 --> world

You can see and try those examples using the demo Makefile example/Makefile.js.

Help

Not specifying any command will attempt to find a command named all.

$ jmake
> error: The command 'all' does not exist in your Makefile.

You can list all available commands by passing -h of --help as the command name:

$ jmake -h
> info: Available commands:
> info:   - hello
> info:   - await
> info:   - error
> info:   - args

Configuration

If you don't like the default name, you can provide a custom name to replace Makefile.js.
To do so, you just have to add a jmake entry to your package.json:

{
    "jmake": "custom-makefile.js"
}

The package.json must be in the directory in which you run jmake or the script won't be able to find it.

License

MIT License

1.0.1

7 years ago

1.0.0

7 years ago

0.1.1

7 years ago

0.1.0

7 years ago