@putout/operator-rename-files
v2.0.0
Published
šPutout operator adds ability to rename files to plugins
Downloads
18,145
Maintainers
Readme
@putout/operator-rename-files
š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:
const {operator} = require('putout');
const {renameFiles} = operator;
module.exports = 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');
},
});
You can also use redlint
directly.
License
MIT