@putout/operator-rename-files
🐊Putout operator adds ability to rename files to plugins
Last updated 2 months ago by coderaiser .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @putout/operator-rename-files 
SYNC missed versions from official npm registry.

@putout/operator-rename-files NPM version

????Putout operator adds ability to rename files to plugins.

Install

npm i putout @putout/operator-rename-files

API

If you want to create ????Putout plugin that will rename files according to your needs just use for ESM:

import {operator} from 'putout';

const {renameFiles} = operator;

export const {
    report,
    fix,
    scan,
} = renameFiles({
    type: 'module',
    mask: '*.mjs',
    rename(name) {
        return name.replace(/mjs$/, 'js');
    },
});

And for CommonJS:

module.exports = renameFiles({
    type: 'commonjs',
    mask: '*.cjs',
    rename(name) {
        return name.replace(/cjs$/, 'js');
    },
});

When you do not need to check type field of package.json, avoid type field:

module.exports = renameFiles({
    mask: '*.cjs',
    rename(name) {
        return name.replace(/cjs$/, 'js');
    },
});

renameFiles({mask, from, to})

You can pass from and to instead of rename for declarative renaming.

export const {
    report,
    fix,
    scan,
} = renameFiles({
    mask: '*.spec.*',
    from: 'spec',
    to: 'test',
});

renameFiles({from, to, near})

Rename files located near package.json:

export const {
    report,
    fix,
    scan,
} = renameFiles({
    from: 'madrun.js',
    to: '.madrun.js',
    near: 'package.json',
});

You can also use redlint directly.

License

MIT

Current Tags

  • 6.2.1                                ...           latest (2 months ago)

15 Versions

  • 6.2.1                                ...           2 months ago
  • 6.2.0                                ...           3 months ago
  • 6.1.2                                ...           3 months ago
  • 6.1.1                                ...           3 months ago
  • 6.1.0                                ...           3 months ago
  • 6.0.3                                ...           3 months ago
  • 6.0.2                                ...           3 months ago
  • 6.0.1                                ...           3 months ago
  • 6.0.0                                ...           4 months ago
  • 5.0.0                                ...           10 months ago
  • 4.0.0                                ...           a year ago
  • 3.0.0                                ...           a year ago
  • 2.0.1                                ...           a year ago
  • 2.0.0                                ...           a year ago
  • 1.0.0                                ...           2 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 1
Last Month 1
Dependencies (1)
Dev Dependencies (13)
Dependents (1)

Copyright 2013 - present © cnpmjs.org | Home |