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

tentacle-js

v1.1.8

Published

Micro build- and task system

Downloads

43

Readme

npm version Dependencies

Installation

You can download the tentacle via NPM or clone the latest release via GitHub.

npm install --save -g tentacle-js

CLI

A command line interface (CLI) is provided by default as you install tentacle. It enables you to run the tentacle scripts from your terminal, dos console or bash. The tentacle binary will look for a file called 'tentacle.js' in your directory where you're executing the tentacle command, so you have to name your file tentacle.js. Using the CLI then is pretty simple and explained with an example below.

Example

# displays version x.x.x (alternate '-V')
tentacle -version

# sets the loglevel to errors only (alternate '-L')
tentacle -loglevel 0

# run in silent mode (alternate '-S')
tentacle -silent

# run a specific task in silent mode
tentacle -tasks default -S

API

Basically you can create several task to execute with different pipes. The only thing you need is an input (files) and eventually an output (folder or file). All functions for this basic process are provided by Tentacle. A guide for the API is avaible below. If something's missing, please open an issue - thanks!

setLogLevel

| Level | Description | |-------|-------------| | -1 | Equivalent to the .silent() method | | 0 | Display only errors | | 1 | Display errors and warnings | | 2 | Display errors, warnings and infos | | 3 | Default - Display errors, warnings, infos and logs (everything) |

Example
var tentacle = require('tentacle-js');
tentacle.setLogLevel(0); // Only errors

task

Creates a task which can be executed by tentacle via CLI or in the default task of your tentaclefile. A task doesn't have to return a stream but if you do any IO activity within your task, it's recommended to use the return statement.

Example
var tentacle = require('tentacle-js');
tentacle.task('example:task', function() {
    console.log('I\'m a task');
});

read

Reads one or multiple files by a global pattern. It can be a regex or a path, no matter what. All files affected by this global path will be passed into the stream of the task and will be modified by your code inside. Use tentacle.write() to set the destination of the files.

Example
var tentacle = require('tentacle-js');
tentacle.task('example:task', function() {
    // Reads all js files form this directory
    return tentacle.read('*.js');
});

write

Writes one or multiple files back to the filesystem. The destination must be a path, otherwise it will create a folder named like your output destination.

Example
var tentacle = require('tentacle-js');
tentacle.task('example:task', function() {
    // Copy all js files form this directory to /copy
    return tentacle.read('*.js')
        .pipe(tentacle.write('/copy'));
});

remote

You can run tentacle scripts on a remote with the embedded method. It uses an SSH2 connection to your server, requiring the host and credentials. Tentacle must be installed on the server before running a script.

Example
var tentacle = require('tentacle-js');
tentacle.remote('/path/to/tentacle.js', {
    user: 'root',
    password: '',
    host: '192.17.210.3'
});

watch

Files can be watched with a global pattern and execute other tasks simultaneously as one of the matching files changes. It is useful for local development and demonstration purposes.

Example
var tentacle = require('tentacle-js');
tentacle.watch('/files/to/watch/**/*.less', function() {
    // Auto-compile less on change of a less file
    tentacle.start('compile:less');
});

run

Basically runs a task defined in tentacle.

Example
var tentacle = require('tentacle-js');
tentacle.run('my-task-name');

silent

Is equivalent to .setLogLevel(-1) and prevents tentacle from logging anything into the console, doesn't matter if it's an error or something else which would be fatal.

Example
var tentacle = require('tentacle-js');
tentacle.silent();

tentacle.task('will-fail', function() {
    throw new Error('Testing silent mode ...');
});

tentacle.task('default', ['will-fail']);
// Console will stay empty

Example Tentacle

This tentacle script will strip all one-line comments out of all JavaScript files located anywhere under the current directory.

'use strict';

var through = require('through2');
var tentacle = require('tentacle-js');
var stripComments = require('strip-comments');

tentacle.task('stripcomments:line', function() {
    return tentacle.read('./**/*.js')
        .pipe(through.obj(function(file, enc, handle) {
            file.contents = new Buffer(
                stripComments.line(file.contents.toString(), {
                    safety: true
                })
            );
            this.push(file);
            return handle();
        }));
});

tentacle.task('default', ['stripcomments:line'])