export-module-csv-files-sync-pmb

1.0.3 • Public • Published

export-module-csv-files-sync-pmb

Turn your collection of CSV files into a node module that exports them.

Usage

  1. Make a new directory for your package.
  2. There, make a node.js script (this example will assume the filename csv2pojo.js) with code like this:
    'use strict';
    module.exports = require('export-module-csv-files-sync-pmb')(module);
  3. Make a package.json with the main key set to "csv2pojo.js".
  4. Put your *.csv files in that same directory or a data/ subdirectory.
  5. Preview: Run nodejs -p "require('.')" to see what your package will export.
  6. Optionally you can add custom configuration, see below.
  7. Optionally generate a JSON and AMD version, see below-
  8. Use and/or publish your package. :-)

Custom config

  1. Replace the (module) part from above with ({ module: module }). That config object is merged with the defaults from cfg.default.js, go have a look for inspiration.
  2. Add and adjust options in your config object as desired and retry the preview step.

Generating JSON and AMD versions

  1. Back up your project, because target files will be overwritten.
  2. If your JSON directory (option overrideJsonDir, default dist) doesn't exist yet, create it.
  3. Run nodejs csv2pojo.js --save-json
  4. Optionally set that command as a git hook, npm pre-publish script or similar, so your JSON and AMD files are kept in sync automatically.

Known issues

  • needs more/better tests and docs

 

License

ISC

Readme

Keywords

none

Package Sidebar

Install

npm i export-module-csv-files-sync-pmb

Weekly Downloads

6

Version

1.0.3

License

ISC

Unpacked Size

8.43 kB

Total Files

4

Last publish

Collaborators

  • mk-pmb