npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

greeklish-file-replace

v1.0.0

Published

Search files for Greek characters and replace them with their greeklish equivalents.

Downloads

16

Readme

greeklish-file-replace

npm package version Travis build status npm package downloads index.js file size code style license

Search files for Greek characters and replace them with their greeklish equivalents.

Installation

npm install [-g] [-S] greeklish-file-replace

Usage

Parameters

Files

The files parameter can accept an array of strings or a single comma-separated string that contains file paths or globs for the files you would like to do the replacements in.

Example:

// A single file path
files = 'path/to/a/file.txt'

// A single glob
files = 'path/to/files/**/*.txt'

// A comma-separated string with both a file path and a glob
files = 'files/replace.txt,files/**/*.js'

// An array of file paths and globs
files = [
  'replace/files/*.txt',
  'file/to/replace.js',
  'more/**/files/*.*'
]

Options

The following options are all optional:

options = {

  // Character encoding for reading/writing files (defaults to utf-8)
  encoding: 'utf-8',

  // Files to replace (only used if `files` parameter is left blank)
  files: 'replace/**/files/*.txt',

  // Characters to ignore during the replacement process (defaults to blank)
  ignoreChars: ';',

  // Files to ignore (works the exact same as `files` parameter)
  ignoreFiles: '**/node_modules/**/*',

  // The directory to save the changed files to (original files will be overwritten if left blank) (defaults to blank)
  output: 'output_directory',

  // Text to add to the beginning of all replacements (defaults to blank)
  prefix: '_[',

  // Text to add to the end of all replacements (defaults to blank)
  suffix: ']_',

  // Set to true to silent all console output (only used in command line) (defaults to false)
  silent: true,

  // Set to true to find out what files are going to be changed without actually changing them (defaults to false)
  test: true,

  // Set to true to add an index number to the end of all repeated replacements or provide a string to use letters instead of numbers (defaults to false)
  unique: 'abcd'

}

Node

Async Promises

const greeklishReplace = require('greeklish-file-replace')

greeklishReplace(files, options)
  .then(results => console.log(results))
  .catch(error => console.log(error))

Async Callbacks

const greeklishReplace = require('greeklish-file-replace')

greeklishReplace(files, options, (error, results) => {
  if (!error) {
    console.log(results)
  } else {
    console.log(error)
  }
})

Sync Function

const greeklishReplace = require('greeklish-file-replace')

var results = greeklishReplace.sync(files, options, cb)

console.log(results)
Sync Callback

The synchronous function accepts a function as an optional third parameter. This function will be called after every replacement with the file name and number of replacements made passed as parameters.

Example:

var results = greeklishReplace.sync(files, options, (file, changes) => {
  if (changes && !options.silent) {
    console.log('Made ' + changes + ' in ' + file)
  }
})

Command Line

greeklish-file-replace files/to/replace/*.txt
  [--files=files/to/replace/**/*.txt]
  [--ignoreChars=";"]
  [--ignoreFiles=files/to/ignore/**/*]
  [--output=output_directory]
  [--prefix="_["]
  [--suffix="]_"]
  [--silent]
  [--test]
  [--unique="abcd"]

Note: When using the files parameter in the command line, your system will take care of expanding your single star globs for us, however it probably won't expand double stars. To get around this, you can use the files option instead (eg. greeklish-files-replace --files=replace/**/*.*).

License

MIT. See the License file for more info.