From 8dc34dae062524a36fab71fbe1cceef9d52c547d Mon Sep 17 00:00:00 2001 From: Austin Andrews Date: Sat, 19 May 2018 12:01:21 -0500 Subject: [PATCH] Update docs and fix typo in util.js --- README.md | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++++-- util.js | 2 +- 2 files changed, 62 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 09f1aed..fa01198 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,61 @@ -# MaterialDesign-Util -Utils for Material Design Icons' Build scripts +# Material Design Icons - Util + +Utility methods for Material Design Icons' Build scripts. + +## Getting Started + +The `@mdi/util` package relies on the `@mdi/svg` package. Any version of `@mdi/svg` can be used. + +``` +npm install @mdi/svg @mdi/util +``` + +- getVersion() +- getMeta([bool withPaths]) +- write(file, data) +- read(file) +- exists(file) + +### getVersion() + +This returns the version of `@mdi/svg` referenced in the `package.json`. + +**returns** semver string `major.minor.build` + +### getMeta([bool withPaths]) + +The main use of this library is to get all the icon data from the `meta.json`. Since the `meta.json` does not contain the SVG path data this method optionally allows this to be added to the object. + +Please reference [meta.json](https://github.com/Templarian/MaterialDesign-SVG/blob/master/meta.json) for more information. + +**returns** icon array [] + +### write(file, data) + +``` +import { write } from '@mdi/util' + +write('file.txt', 'Hello World!') +``` + +### read(file) + +``` +import { read } from '@mdi/util' + +const foo = read('file.txt') +``` + +**returns** string of file contents + +### exists(file) + +``` +import { exists } from '@mdi/util' + +if (exits('file.txt')) { + // file exists! +} +``` + +**returns** bool `true`/`false` if file exists diff --git a/util.js b/util.js index 5369d67..4518831 100644 --- a/util.js +++ b/util.js @@ -25,7 +25,7 @@ exports.write = (file, data) => { fs.writeFileSync(file, data); }; -exports.read = (file, data) => { +exports.read = (file) => { fs.readFileSync(file); };