1.2.1 • Published 5 years ago

electer v1.2.1

Weekly downloads
1
License
ISC
Repository
github
Last release
5 years ago

electer

electer is a set of utilities to find and query for any specific data from your project directory. Great for finding any files that are importing a specific package, swapping old for new code, etc.

Why?

Migrating old imports and other code in previous files is a hassle if you're checking each file manually. With these utilities, you are able to query all the custom data you need from your files in no time.

Contributing

Submit issues / pull requests / fixes / anything.

Installation

npm i --save electer

Usage

ES6 import:

import electer from 'electer'

CommonJS import:

const electer = require('electer')

.bundle (paths: string[], bundle: Bundle = { files: [], folders: [] }) => Bundle

Takes in a list of paths, and separates them between files and folders, respectively. Returns an object with the shape { files: [], folders: [] } (Bundle)

const bundle = electer.bundle(paths)
console.log(bundle)
// Output:   { files: [path1, path2, ...], folders: [path1, path2, ...] }

.bundleFilesDeep (path: string, bundle: Bundle = { files: [], folders: [] }) => Bundle

Takes in a single path (folder/directory), recursively traverses subdirectories and separates them between files and folders into a final Bundle, respectively. Returns an object with the shape { files: [], folders: [] } (Bundle)

const bundle = electer.bundleFilesDeep(
  'src/components',
  { files: [...], folders: [...]}
)
console.log(bundle)
// Output:   { files: [path1, path2, ...], folders: [path1, path2, ...] }

.toPaths (dir: string) => string[]

Reads a path (folder/directory) and returns a list of files/folders as full paths inside the directory (not sub-directories) as an array of strings.

const paths = electer.toPaths('src/components')
console.log(paths)

//    Output:
//      [
//        'C:\\Users\\molin\\soup\\src\\rocks.ts',
//        'C:\\Users\\molin\\soup\\src\\index.ts',
//        'C:\\Users\\molin\\soup\\src\\types'
//      ]

.find (path: string, query: string) => string[]

Reads a path (folder/directory), traverses/reads each file (not subdirectories) and returns a list of files as an array of strings that contain the given query.

const filesWithQuery = electer.find('src/components', 'kale')
console.log(filesWithQuery)

//    Output:
//     [
//       'C:/Users/pfftd/foods/everything-you-need-to-know-about-kale.md',
//       'C:/Users/pfftd/foods/this-is-how-kale-can-save-your-health.md',
//       'C:/Users/pfftd/foods/kale/essay-kale-12-18-2018.docx'
//     ]
1.2.1

5 years ago

1.2.0

5 years ago

1.1.5

5 years ago

1.1.4

5 years ago

1.1.3

5 years ago

1.1.2

5 years ago

1.1.0

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago