Skip to Content
  • Website
Codsen
  • Home
  • Open Source
  • Articles
  • About

prevOpen Source→js-row-num-clinext

js-row-num-cli4.2.1

Update all row numbers in all console.logs in given files

Downloads per monthChangelogMIT Licenselibera manifesto
  • the top
  • Installation
  • USE IT
  • QUICK TAKE
  • API
  • USING MULTIPL…
  • ESCAPING
  • LINTERS
  • Changelog

Installation

Use it

in terminal
in terminal

Once installed, call it typing jsrownum or jrn in your terminal, like this:

jsrownum
# or
jrn

or specify a glob pointing to some .js (or .ts or any other) files:

jsrownum "folder/*.js"
# or
jrn "folder/*.js"

If jsrownum is too long, you can also type jrn; we wired up that as an alternative.

Quick Take

It updates each console.log in your .js files…

from:

// something on row 1
// something on row 2
console.log('000 var = ' + var); // row 3
//           ^^^

to:

// ...
console.log('003 var = ' + var);
//           ^^^

Because it’s on row 3. If you’re not using console.log, and are using for example log(), put that under “-t” flag:

jrn -t "log"

or if specifying paths,

jrn "folder/*.js" -t "log"

API

Once installed globally, type in your terminal: jsrownum OR type jrn.

If you won’t pass any glob file/folder pattern or patterns, for example, just type jrn, it will look for the following files in this priority order:

  1. ./src/main.js
  2. ./main.js
  3. ./cli.js
  4. ./index.js
  5. ./src/index.js

If you will pass some globs, for example:

jrn "src/*.js"
jsrownum --pad="4" "dist/**/*.js test/ index.js"
jrn "test1.js test2.js" -p 2

...it will expand the globs and catch all specified files and process them.

Optionally, you can pass the options, which match the API:

CLI flagFor example,What it does
-p or --pad
-p or --padjsrownum -p 3 or jrn --pad="4"Lets you set the row number padding. For example, console.log statement on row 3 with padding set to 4 would get 0003 added. Row 99 with padding of 1 would be still 99.
-t or --trigger
-t or --triggerjrn -t "log"Lets you change from “console.log” to any function’s name

Using multiple flags

Command line applications have few rules. First, if you want to pass multiple values to a certain flag, put -* or --***** for each value:

GOOD:

jrn -f "log" -f "yo"

BAD:

jrn -f "log" "yo"

Escaping

If you want to put double quotes, escape it like using left slash:

jrn -f "zzz\"yyy"

Linters

When working with your own code, it’s more efficient to set up a linting rule,eslint-plugin-row-num — line number updating will become seamless and will happen in your code editor.

Lately, I have found use for js-row-num-cli. I use it when tinkering with 3rd party packages, both right in node_modules (quickly investigating bugs in dependencies) and also in forked packages.

When working with forked packages, I need console.log row reporting but it’s tedious to temporarily add the eslint-plugin-row-num to particular project’s linting setup — dependencies get installed, lockfiles get updated — remember to remove it in the end — it’s easier to use globally-installed js-row-num-cli and call it directly on source files.

Changelog

Open Changelog
↑ back to top
prev next

Copyright

All rights reserved © Roy Revelt 2026
All our open source packages are under MIT licenceopens in a new tab

Activities

🐛 See a bug? Raise an issueopens in a new tab
💘 Check out the Indiewebopens in a new tab and Libera manifestoopens in a new tab