linemod
v2.0.1
Published
Comment driven line modifications
Downloads
139
Readme
Linemod
CLI companion for linemod-core, a comment driven line modification tool.
Usage
As npm script
"scripts": {
"test": "linemod -e new index.js lib/utils.js"
}
Command line
npm install -g linemod
Then run it at on your files that has modifications:
linemod -e new index.js lib/utils.js
If your command line supports globbing, then you can do:
linemod -e new *.js lib/**/*.js
Programmatic use
Use linemod-core directly.
Flags
--extension
/-e
– required – the file extension used on the output files.
Additional command line flags
--help
/-h
– prints all available flags--strict
/-s
– treats warnings as errors--verbose
/-v
– prints warnings and notices
Available modifications
All linemod-core
modifications are supported. Linemods are added at the end of the line they are supposed to apply to.
linemod-add:
Prefixes the line with whatever is specified after the keyword:
// linemod-add: import escape from 'stringify-entities';
Becomes:
import escape from 'stringify-entities';
linemod-prefix-with:
Prefixes the line with whatever is specified after the keyword:
const exportedMethod = () => {}; // linemod-prefix-with: export
Becomes:
export const exportedMethod = () => {};
linemod-replace-with:
Replaces the line with whatever is specified after the keyword:
const escape = require('stringify-entities'); // linemod-replace-with: import escape from 'stringify-entities';
Becomes:
import escape from 'stringify-entities';
linemod-remove
Simply removes the entire line.
Quite useful when combined with linemod-prefix-with
:
const exportedMethod = () => {}; // linemod-prefix-with: export
module.exports = { exportedMethod }; // linemod-remove
Becomes:
export const exportedMethod = () => {};