1.0.3 • Published 6 years ago
export-module-csv-files-sync-pmb v1.0.3
export-module-csv-files-sync-pmb
Turn your collection of CSV files into a node module that exports them.
Usage
- Make a new directory for your package.
- 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); - Make a
package.jsonwith themainkey set to"csv2pojo.js". - Put your
*.csvfiles in that same directory or adata/subdirectory. - Preview: Run
nodejs -p "require('.')"to see what your package will export. - Optionally you can add custom configuration, see below.
- Optionally generate a JSON and AMD version, see below-
- Use and/or publish your package. :-)
Custom config
- 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. - Add and adjust options in your config object as desired and retry the preview step.
Generating JSON and AMD versions
- Back up your project, because target files will be overwritten.
- If your JSON directory (option
overrideJsonDir, defaultdist) doesn't exist yet, create it. - Run
nodejs csv2pojo.js --save-json - 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