A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/mcandre/booty below:

mcandre/booty: the biggest thing to happen to ECMAScript since Netscape

booty: the biggest thing to happen to ECMAScript since Netscape

booty is a convention for writing development tasks for JavaScript (Node.js) projects, via npm run hooks.

Tasks are implemented using modern JavaScript code. We can use a directory like tasks/ to house task definitions.

Here, a groceries task

#!/usr/bin/env node
'use strict';

import child_process from 'node:child_process';
import process from 'node:process';

export default function groceries() {
    child_process.execSync('echo milk...', { stdio: 'inherit' });
    child_process.execSync('echo eggs...', { stdio: 'inherit' });
    child_process.execSync('echo just browsing', { stdio: 'inherit' });
}

function main() {
    groceries();
}

if (import.meta.url === `file://${process.argv[1]}`) { main(); }

Take care to avoid colliding with conventional NPM life cycle task names.

It's often a good idea to configure a clean task to automate resetting the development environment.

#!/usr/bin/env node
'use strict';

import fs from 'node:fs';
import process from 'node:process';

export default function clean() {
    console.log('removing junk files...');

    fs.rmSync('nosuchdirectory', { force: true, recursive: true });
    fs.rmSync('nosuchfile.dat', { force: true });
}

function main() {
    clean();
}

if (import.meta.url === `file://${process.argv[1]}`) { main(); }

Subtasks can be aggregated together into higher level tasks.

Let's prepare all our errands to trigger together.

#!/usr/bin/env node
'use strict';

import groceries from './groceries';
import clean from './clean';

import process from 'node:process';

function main() {
    groceries();
    clean();
}

if (import.meta.url === `file://${process.argv[1]}`) { main(); }

You can group or divide tasks into hierarchy shapes as needed, depending on the complexity of the tasks and the frequency of low level tasks.

Then, wire up each task to the npm run system.

{
    "name": "@mcandre/hello-booty",
    "scripts": {
        "all": "./tasks/all",
        "groceries": "./tasks/groceries",
        "clean": "./tasks/clean"
    },
    "type": "module"
}

Compared to modern task runners, the npm run system has some quirks:

🍑


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4