Skip to content
This repository has been archived by the owner on Jun 27, 2021. It is now read-only.

Scripts

Marcel Kloubert edited this page Jul 4, 2019 · 1 revision

Scripts

With the help of run command, you can implement Node.js based scripts.

Create a .js file, like test.js, and use the following skeleton:

exports.execute = async (context) => {
    // context  =>  s. https://egodigital.github.io/ego-cli/interfaces/_contracts_.commandexecutecontext.html

    // context.args           =>  List of command line arguments, s. https://www.npmjs.com/package/minimist
    // context.cwd            =>  The full path of the current working directory
    // context.getFullPath()  =>  Returns the full version of a path, based on the value of 'cwd'
    // context.package        =>  The 'package.json' file of the e.GO CLI
    // context.queue          =>  A queue, that only executes 1 action at the same time, s. https://www.npmjs.com/package/p-queue
    // context.require()      =>  Allows to include a NPM module of the e.GO CLI
    // context.values         =>  A key/value pair storage, that is available while the execution
    // context.verbose        =>  Indicates, if script should output additional information or not

    // docker utils, s. https://egodigital.github.io/ego-cli/modules/_docker_.html
    const docker = context.require('./docker');
    // git utils, s. https://egodigital.github.io/ego-cli/modules/_git_.html
    const git = context.require('./git');
    // common app utils, s. https://egodigital.github.io/ego-cli/modules/_util_.html
    const util = context.require('./util');

    util.writeLine('Hello, from ' + __filename);
};

You can run the script, by executing

ego run test.js

from the folder, that contains the file.

You are also able to store it globally, inside the .ego subfolder, inside your user's home directory (${HOME}/.ego/test.js).

Clone this wiki locally