1.0.5 • Published 4 years ago

ntransformer v1.0.5

Weekly downloads
6
License
ISC
Repository
github
Last release
4 years ago

ntransformer

This package can help you to change substrings of directory names, file names and file content. Also it does it recursively, so you can change all occurences under certain directory.

Written purely using TypeScript, so it's strongly typed

All function have config parameter maxDepth which control depth of recursion

Run npm i ntransformer to install package


Changing file names:

Changes searchKey with replaceKey in file names under path recursively

Example use of updateFileNames

const ntransformer = require("ntransformer");

ntransformer.updateFileNames({ 
  searchKey: 'searchkey',
  replaceKey: 'replaceKey',
  path: path.join(__dirname, "target-folder")
})
ConfigValuesRequiredDescription
pathstring (Default = __dirname)Noabsolute path
searchKeystring | RegExp (case sensitive)Yessearch key substring
replaceKeystringYesreplace key
maxDepthnumber (Default = 10)Nomaximum recursion depth

Application image


Changing directory names:

Changes searchKey with replaceKey in directory names under path recursively

Example use of updateDirectoryNames

const ntransformer = require("ntransformer");

ntransformer.updateDirectoryNames({ 
  searchKey: 'searchkey',
  replaceKey: 'replaceKey',
  path: path.join(__dirname, "target-folder")
})
ConfigValuesRequiredDescription
pathstring (Default = __dirname)Noabsolute path
searchKeystring | RegExp (case sensitive)Yessearch key substring
replaceKeystringYesreplace key
maxDepthnumber (Default = 10)Nomaximum recursion depth

Application image


Replacing file contents:

Replaces searchKey with replaceKey in all allowed (by extensions) files under path recursively

Example use of updateFileContent

const ntransformer = require("ntransformer");

ntransformer.updateFileContent({ 
  searchKey: 'searchkey',
  replaceKey: 'replaceKey',
  path: path.join(__dirname, "target-folder"),
  permittedFileExtensions: [".txt", ".js", ".ts", ".json"]
})
ConfigValuesRequiredDescription
pathstring (Default = __dirname)Noabsolute path
searchKeystring | RegExp (case sensitive)Yessearch key substring
replaceKeystringYesreplace key
maxDepthnumber (Default = 10)Nomaximum recursion depth
permittedFileExtensionsArray of string (Default = ".txt", ".js", ".ts", ".json")Nomaximum recursion depth