Comment driven line modifications
npm install linemod-coreComment driven line modifications






``javascript
import { linemod } from 'linemod-core';
import pathModule from 'node:path';
await linemod(
[pathModule.resolve(__dirname, 'index.js')],
{ outputExtension: '.mjs' }
);
`
`javascript`
const { linemod } = await import('linemod-core');
Takes an array of string file paths (paths), applies modifications to them and outputs them to the same destination with the specified extension (outputExtension)
Same as linemod(), but takes a single string file path (path) rather than an array.
Applies any modifications on the string input (content) and returns back the resulting string.
Linemods are added at the end of the line they are supposed to apply to.
Prefixes the line with whatever is specified after the keyword:
`javascript`
// linemod-add: import escape from 'stringify-entities';
Becomes:
`javascript`
import escape from 'stringify-entities';
Prefixes the line with whatever is specified after the keyword:
`javascript`
const exportedMethod = () => {}; // linemod-prefix-with: export
Becomes:
`javascript`
export const exportedMethod = () => {};
Replaces the line with whatever is specified after the keyword:
`javascript`
const escape = require('stringify-entities'); // linemod-replace-with: import escape from 'stringify-entities';
Becomes:
`javascript`
import escape from 'stringify-entities';
Simply removes the entire line.
Quite useful when combined with linemod-prefix-with:
`javascript`
const exportedMethod = () => {}; // linemod-prefix-with: export
module.exports = { exportedMethod }; // linemod-remove
Becomes:
`javascript``
export const exportedMethod = () => {};